Viewing File server/web/monitor.php of 1.04.0a
|
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 FreeNATS. 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: 27: // Timeskip check - means this page skips timecheck/reset if site.monitor.keepalive is 0 28: if ($NATS->Cfg->Get("site.monitor.keepalive",1)==0) $timeskip=true; 29: else $timeskip=false; 30: 31: if (!$NATS_Session->Check($NATS->DB,$timeskip)) 32: { 33: header("Location: ./?login_msg=Invalid+Or+Expired+Session"); 34: exit(); 35: } 36: if ($NATS_Session->userlevel<1) UL_Error("View Monitor"); 37: 38: if (isset($_REQUEST['style'])) 39: { 40: $style=$_REQUEST['style']; 41: setcookie("fn_monitorstyle",$style); 42: } 43: else if (isset($_COOKIE['fn_monitorstyle'])) 44: { 45: $style=$_COOKIE['fn_monitorstyle']; 46: } 47: else $style="standard"; 48: 49: if ($style=="") $style="standard"; 50: 51: Screen_Header("Live Monitor",1,1,"<meta http-equiv=\"refresh\" content=\"60\">"); 52: ?> 53: <br> 54: 55: <div class="monitorviews" id="monitorviews_div"> 56: <a href="javascript:showMonitorViews()">options...</a> 57: </div> 58: 59: <script type="text/javascript"> 60: var dispOptions=new Array(); 61: var dispLink=new Array(); 62: 63: var optCount=0; 64: dispOptions[optCount]='standard'; 65: dispLink[optCount++]='standard'; 66: dispOptions[optCount]='groups'; 67: dispLink[optCount++]='groups'; 68: dispOptions[optCount]='nodes'; 69: dispLink[optCount++]='nodes'; 70: dispOptions[optCount]='alerting'; 71: dispLink[optCount++]='alerting'; 72: 73: function showMonitorViews() 74: { 75: var content=''; 76: for (var a=0; a<optCount; a++) 77: { 78: content=content+'<a href=monitor.php?style='+dispOptions[a]+'>'; 79: content=content+'<img src=images/monitor_thumb/'+dispOptions[a]+'.png border=0><br>'+dispLink[a]+'</a><br><br>'; 80: } 81: content=content+'<a href="javascript:hideMonitorViews()">...hide...</a>'; 82: document.getElementById('monitorviews_div').innerHTML=content; 83: } 84: 85: function hideMonitorViews() 86: { 87: document.getElementById('monitorviews_div').innerHTML='<a href="javascript:showMonitorViews()">options...</a>'; 88: } 89: 90: <?php 91: if (isset($_REQUEST['showviewoption'])) echo "showMonitorViews();\n"; 92: ?> 93: </script> 94: 95: <?php 96: 97: 98: ob_end_flush(); 99: 100: if ($style=="standard") 101: { 102: 103: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 104: $r=$NATS->DB->Query($q); 105: 106: if ($NATS->DB->Num_Rows($r)>0) 107: { 108: echo "<table border=0>"; 109: $a=0; 110: while ($row=$NATS->DB->Fetch_Array($r)) 111: { 112: if ($a==0) echo "<tr>"; 113: echo "<td>"; 114: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 115: echo "</td>"; 116: $a++; 117: if ($a==2) 118: { 119: $a=0; 120: echo "</tr>"; 121: } 122: } 123: if ($a>0) echo "</tr>"; 124: echo "</table>"; 125: echo "<br><br>"; 126: } 127: 128: 129: $NATS->DB->Free($r); 130: 131: 132: $q="SELECT * FROM fnnode ORDER BY alertlevel DESC, weight ASC"; 133: $r=$NATS->DB->Query($q); 134: 135: echo "<table border=0>"; 136: $a=0; 137: while ($row=$NATS->DB->Fetch_Array($r)) 138: { 139: if ($a==0) echo "<tr>"; 140: echo "<td>"; 141: np_tiny($row['nodeid'],true,$row['nodename']); 142: echo "</td>"; 143: $a++; 144: if ($a==5) 145: { 146: $a=0; 147: echo "</tr>"; 148: } 149: } 150: if ($a>0) echo "</tr>"; 151: echo "</table>"; 152: $NATS->DB->Free($r); 153: } 154: 155: else if ($style=="alerting") 156: { 157: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 158: $r=$NATS->DB->Query($q); 159: 160: echo "<table border=0>"; 161: $a=0; 162: while ($row=$NATS->DB->Fetch_Array($r)) 163: { 164: if ($NATS->GroupAlertLevel($row['groupid'])>0) 165: { 166: if ($a==0) echo "<tr>"; 167: echo "<td>"; 168: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 169: echo "</td>"; 170: $a++; 171: if ($a==2) 172: { 173: $a=0; 174: echo "</tr>"; 175: } 176: } 177: } 178: if ($a>0) echo "</tr>"; 179: echo "</table>"; 180: 181: 182: $NATS->DB->Free($r); 183: 184: echo "<br><br>"; 185: 186: $q="SELECT * FROM fnnode WHERE alertlevel!=0 ORDER BY alertlevel DESC, weight ASC"; 187: $r=$NATS->DB->Query($q); 188: 189: echo "<table border=0>"; 190: $a=0; 191: while ($row=$NATS->DB->Fetch_Array($r)) 192: { 193: if ($a==0) echo "<tr>"; 194: echo "<td>"; 195: np_tiny($row['nodeid'],true,$row['nodename']); 196: echo "</td>"; 197: $a++; 198: if ($a==5) 199: { 200: $a=0; 201: echo "</tr>"; 202: } 203: } 204: if ($a>0) echo "</tr>"; 205: echo "</table>"; 206: $NATS->DB->Free($r); 207: } 208: 209: else if ($style=="groups") 210: { 211: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 212: $r=$NATS->DB->Query($q); 213: 214: echo "<table border=0>"; 215: $a=0; 216: while ($row=$NATS->DB->Fetch_Array($r)) 217: { 218: if ($a==0) echo "<tr>"; 219: echo "<td>"; 220: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 221: echo "</td>"; 222: $a++; 223: if ($a==2) 224: { 225: $a=0; 226: echo "</tr>"; 227: } 228: } 229: if ($a>0) echo "</tr>"; 230: echo "</table>"; 231: 232: 233: $NATS->DB->Free($r); 234: } 235: 236: else if ($style=="nodes") 237: { 238: $q="SELECT * FROM fnnode ORDER BY alertlevel DESC, weight ASC"; 239: $r=$NATS->DB->Query($q); 240: 241: echo "<table border=0>"; 242: $a=0; 243: while ($row=$NATS->DB->Fetch_Array($r)) 244: { 245: if ($a==0) echo "<tr>"; 246: echo "<td>"; 247: np_big($row['nodeid'],$row['nodename'],$row['nodedesc'],$row['nodeicon']); 248: echo "</td>"; 249: $a++; 250: if ($a==2) 251: { 252: $a=0; 253: echo "</tr>"; 254: } 255: } 256: if ($a>0) echo "</tr>"; 257: echo "</table>"; 258: 259: 260: $NATS->DB->Free($r); 261: } 262: 263: else 264: { 265: echo "<b>Sorry - unknown display style type</b><br><br>"; 266: } 267: 268: mt_srand(microtime()*1000000); 269: if (mt_rand(0,100)==50) $track_if_enabled=true; 270: else $track_if_enabled=false; 271: 272: Screen_Footer($track_if_enabled); 273: ?> 274: