Viewing File server/web/monitor.php of 1.00.7a
|
1: <?php 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: FreeNATS is (C) Copyright 2008 PurplePixie Systems 6: 7: FreeNATS is free software: you can redistribute it and/or modify 8: it under the terms of the GNU General Public License as published by 9: the Free Software Foundation, either version 3 of the License, or 10: (at your option) any later version. 11: 12: FreeNATS is distributed in the hope that it will be useful, 13: but WITHOUT ANY WARRANTY; without even the implied warranty of 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15: GNU General Public License for more details. 16: 17: You should have received a copy of the GNU General Public License 18: along with Foobar. If not, see www.gnu.org/licenses 19: 20: For more information see www.purplepixie.org/freenats 21: -------------------------------------------------------------- */ 22: 23: ob_start(); 24: require("include.php"); 25: $NATS->Start(); 26: if (!$NATS_Session->Check($NATS->DB)) 27: { 28: header("Location: ./?login_msg=Invalid+Or+Expired+Session"); 29: exit(); 30: } 31: if ($NATS_Session->userlevel<1) UL_Error("View Monitor"); 32: 33: Screen_Header("Live Monitor",1,1,"<meta http-equiv=\"refresh\" content=\"60\">"); 34: ?> 35: <br> 36: 37: <div class="monitorviews" id="monitorviews_div"> 38: <a href="javascript:showMonitorViews()">options...</a> 39: </div> 40: 41: <script type="text/javascript"> 42: var dispOptions=new Array(); 43: var dispLink=new Array(); 44: 45: var optCount=0; 46: dispOptions[optCount]='standard'; 47: dispLink[optCount++]='standard'; 48: dispOptions[optCount]='groups'; 49: dispLink[optCount++]='groups'; 50: dispOptions[optCount]='nodes'; 51: dispLink[optCount++]='nodes'; 52: dispOptions[optCount]='alerting'; 53: dispLink[optCount++]='alerting'; 54: 55: function showMonitorViews() 56: { 57: var content=''; 58: for (var a=0; a<optCount; a++) 59: { 60: content=content+'<a href=monitor.php?style='+dispOptions[a]+'>'; 61: content=content+'<img src=images/monitor_thumb/'+dispOptions[a]+'.png border=0><br>'+dispLink[a]+'</a><br><br>'; 62: } 63: content=content+'<a href="javascript:hideMonitorViews()">...hide...</a>'; 64: document.getElementById('monitorviews_div').innerHTML=content; 65: } 66: 67: function hideMonitorViews() 68: { 69: document.getElementById('monitorviews_div').innerHTML='<a href="javascript:showMonitorViews()">options...</a>'; 70: } 71: 72: <?php 73: if (isset($_REQUEST['showviewoption'])) echo "showMonitorViews();\n"; 74: ?> 75: </script> 76: 77: <?php 78: 79: if (isset($_REQUEST['style'])) 80: { 81: $style=$_REQUEST['style']; 82: setcookie("fn_monitorstyle",$style); 83: } 84: else if (isset($_COOKIE['fn_monitorstyle'])) 85: { 86: $style=$_COOKIE['fn_monitorstyle']; 87: } 88: else $style="standard"; 89: 90: if ($style=="") $style="standard"; 91: 92: ob_end_flush(); 93: 94: if ($style=="standard") 95: { 96: 97: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 98: $r=$NATS->DB->Query($q); 99: 100: if ($NATS->DB->Num_Rows($r)>0) 101: { 102: echo "<table border=0>"; 103: $a=0; 104: while ($row=$NATS->DB->Fetch_Array($r)) 105: { 106: if ($a==0) echo "<tr>"; 107: echo "<td>"; 108: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 109: echo "</td>"; 110: $a++; 111: if ($a==2) 112: { 113: $a=0; 114: echo "</tr>"; 115: } 116: } 117: if ($a>0) echo "</tr>"; 118: echo "</table>"; 119: echo "<br><br>"; 120: } 121: 122: 123: $NATS->DB->Free($r); 124: 125: 126: $q="SELECT * FROM fnnode ORDER BY alertlevel DESC, weight ASC"; 127: $r=$NATS->DB->Query($q); 128: 129: echo "<table border=0>"; 130: $a=0; 131: while ($row=$NATS->DB->Fetch_Array($r)) 132: { 133: if ($a==0) echo "<tr>"; 134: echo "<td>"; 135: np_tiny($row['nodeid'],true,$row['nodename']); 136: echo "</td>"; 137: $a++; 138: if ($a==5) 139: { 140: $a=0; 141: echo "</tr>"; 142: } 143: } 144: if ($a>0) echo "</tr>"; 145: echo "</table>"; 146: $NATS->DB->Free($r); 147: } 148: 149: else if ($style=="alerting") 150: { 151: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 152: $r=$NATS->DB->Query($q); 153: 154: echo "<table border=0>"; 155: $a=0; 156: while ($row=$NATS->DB->Fetch_Array($r)) 157: { 158: if ($NATS->GroupAlertLevel($row['groupid'])>0) 159: { 160: if ($a==0) echo "<tr>"; 161: echo "<td>"; 162: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 163: echo "</td>"; 164: $a++; 165: if ($a==2) 166: { 167: $a=0; 168: echo "</tr>"; 169: } 170: } 171: } 172: if ($a>0) echo "</tr>"; 173: echo "</table>"; 174: 175: 176: $NATS->DB->Free($r); 177: 178: echo "<br><br>"; 179: 180: $q="SELECT * FROM fnnode WHERE alertlevel!=0 ORDER BY alertlevel DESC, weight ASC"; 181: $r=$NATS->DB->Query($q); 182: 183: echo "<table border=0>"; 184: $a=0; 185: while ($row=$NATS->DB->Fetch_Array($r)) 186: { 187: if ($a==0) echo "<tr>"; 188: echo "<td>"; 189: np_tiny($row['nodeid'],true,$row['nodename']); 190: echo "</td>"; 191: $a++; 192: if ($a==5) 193: { 194: $a=0; 195: echo "</tr>"; 196: } 197: } 198: if ($a>0) echo "</tr>"; 199: echo "</table>"; 200: $NATS->DB->Free($r); 201: } 202: 203: else if ($style=="groups") 204: { 205: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 206: $r=$NATS->DB->Query($q); 207: 208: echo "<table border=0>"; 209: $a=0; 210: while ($row=$NATS->DB->Fetch_Array($r)) 211: { 212: if ($a==0) echo "<tr>"; 213: echo "<td>"; 214: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 215: echo "</td>"; 216: $a++; 217: if ($a==2) 218: { 219: $a=0; 220: echo "</tr>"; 221: } 222: } 223: if ($a>0) echo "</tr>"; 224: echo "</table>"; 225: 226: 227: $NATS->DB->Free($r); 228: } 229: 230: else if ($style=="nodes") 231: { 232: $q="SELECT * FROM fnnode ORDER BY alertlevel DESC, weight ASC"; 233: $r=$NATS->DB->Query($q); 234: 235: echo "<table border=0>"; 236: $a=0; 237: while ($row=$NATS->DB->Fetch_Array($r)) 238: { 239: if ($a==0) echo "<tr>"; 240: echo "<td>"; 241: np_big($row['nodeid'],$row['nodename'],$row['nodedesc'],$row['nodeicon']); 242: echo "</td>"; 243: $a++; 244: if ($a==2) 245: { 246: $a=0; 247: echo "</tr>"; 248: } 249: } 250: if ($a>0) echo "</tr>"; 251: echo "</table>"; 252: 253: 254: $NATS->DB->Free($r); 255: } 256: 257: else 258: { 259: echo "<b>Sorry - unknown display style type</b><br><br>"; 260: } 261: 262: mt_srand(microtime()*1000000); 263: if (mt_rand(0,100)==50) $track_if_enabled=true; 264: else $track_if_enabled=false; 265: 266: Screen_Footer($track_if_enabled); 267: ?> 268: