Viewing File server/web/monitor.php of 1.09.4a
|
1: <?php 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: FreeNATS is (C) Copyright 2008-2010 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: <?php 60: /* 61: echo "<style type=\"text/css\">\n"; 62: include("css/monitor.css"); 63: echo "\n</style>\n"; 64: */ 65: ?> 66: <link rel="stylesheet" type="text/css" href="css/monitor.css" /> 67: <?php 68: if ($NATS->Cfg->Get("site.monitor.popup",1)==0) $monpopup=false; 69: else if ($NATS->Cfg->Get("dev.monitor.popup",0)==1) $monpopup=true; // dev testing 70: else $monpopup=false; 71: 72: if ($monpopup) 73: { 74: echo "<div class=\"monitor_popup\" id=\"popup_div\"></div>"; 75: echo "<script type=\"text/javascript\" src=\"js/monitor.popup.js\">\n"; 76: echo "</script>\n"; 77: } 78: ?> 79: 80: <script type="text/javascript"> 81: var dispOptions=new Array(); 82: var dispLink=new Array(); 83: 84: var optCount=0; 85: dispOptions[optCount]='standard'; 86: dispLink[optCount++]='standard'; 87: dispOptions[optCount]='groups'; 88: dispLink[optCount++]='groups'; 89: dispOptions[optCount]='nodes'; 90: dispLink[optCount++]='nodes'; 91: dispOptions[optCount]='alerting'; 92: dispLink[optCount++]='alerting'; 93: 94: function showMonitorViews() 95: { 96: var content=''; 97: for (var a=0; a<optCount; a++) 98: { 99: content=content+'<a href=monitor.php?style='+dispOptions[a]+'>'; 100: content=content+'<img src=images/monitor_thumb/'+dispOptions[a]+'.png border=0><br>'+dispLink[a]+'</a><br><br>'; 101: } 102: content=content+'<a href="javascript:hideMonitorViews()">...hide...</a>'; 103: document.getElementById('monitorviews_div').innerHTML=content; 104: } 105: 106: function hideMonitorViews() 107: { 108: document.getElementById('monitorviews_div').innerHTML='<a href="javascript:showMonitorViews()">options...</a>'; 109: } 110: 111: <?php 112: if (isset($_REQUEST['showviewoption'])) echo "showMonitorViews();\n"; 113: ?> 114: </script> 115: 116: <?php 117: 118: 119: ob_end_flush(); 120: 121: if ($style=="standard") 122: { 123: 124: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 125: $r=$NATS->DB->Query($q); 126: 127: if ($NATS->DB->Num_Rows($r)>0) 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: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 136: echo "</td>"; 137: $a++; 138: if ($a==2) 139: { 140: $a=0; 141: echo "</tr>"; 142: } 143: } 144: if ($a>0) echo "</tr>"; 145: echo "</table>"; 146: echo "<br><br>"; 147: } 148: 149: 150: $NATS->DB->Free($r); 151: 152: 153: $q="SELECT * FROM fnnode ORDER BY alertlevel DESC, weight ASC"; 154: $r=$NATS->DB->Query($q); 155: 156: echo "<table border=0>"; 157: $a=0; 158: while ($row=$NATS->DB->Fetch_Array($r)) 159: { 160: if ($a==0) echo "<tr>"; 161: echo "<td>"; 162: np_tiny($row['nodeid'],true,$row['nodename'],$monpopup); 163: echo "</td>"; 164: $a++; 165: if ($a==5) 166: { 167: $a=0; 168: echo "</tr>"; 169: } 170: } 171: if ($a>0) echo "</tr>"; 172: echo "</table>"; 173: $NATS->DB->Free($r); 174: } 175: 176: else if ($style=="alerting") 177: { 178: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 179: $r=$NATS->DB->Query($q); 180: 181: echo "<table border=0>"; 182: $a=0; 183: while ($row=$NATS->DB->Fetch_Array($r)) 184: { 185: if ($NATS->GroupAlertLevel($row['groupid'])>0) 186: { 187: if ($a==0) echo "<tr>"; 188: echo "<td>"; 189: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 190: echo "</td>"; 191: $a++; 192: if ($a==2) 193: { 194: $a=0; 195: echo "</tr>"; 196: } 197: } 198: } 199: if ($a>0) echo "</tr>"; 200: echo "</table>"; 201: 202: 203: $NATS->DB->Free($r); 204: 205: echo "<br><br>"; 206: 207: $q="SELECT * FROM fnnode WHERE alertlevel!=0 ORDER BY alertlevel DESC, weight ASC"; 208: $r=$NATS->DB->Query($q); 209: 210: echo "<table border=0>"; 211: $a=0; 212: while ($row=$NATS->DB->Fetch_Array($r)) 213: { 214: if ($a==0) echo "<tr>"; 215: echo "<td>"; 216: np_tiny($row['nodeid'],true,$row['nodename'],$monpopup); 217: echo "</td>"; 218: $a++; 219: if ($a==5) 220: { 221: $a=0; 222: echo "</tr>"; 223: } 224: } 225: if ($a>0) echo "</tr>"; 226: echo "</table>"; 227: $NATS->DB->Free($r); 228: } 229: 230: else if ($style=="groups") 231: { 232: $q="SELECT * FROM fngroup ORDER BY 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: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon'],$monpopup); 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 if ($style=="nodes") 258: { 259: $q="SELECT * FROM fnnode ORDER BY alertlevel DESC, weight ASC"; 260: $r=$NATS->DB->Query($q); 261: 262: echo "<table border=0>"; 263: $a=0; 264: while ($row=$NATS->DB->Fetch_Array($r)) 265: { 266: if ($a==0) echo "<tr>"; 267: echo "<td>"; 268: np_big($row['nodeid'],$row['nodename'],$row['nodedesc'],$row['nodeicon'],$monpopup); 269: echo "</td>"; 270: $a++; 271: if ($a==2) 272: { 273: $a=0; 274: echo "</tr>"; 275: } 276: } 277: if ($a>0) echo "</tr>"; 278: echo "</table>"; 279: 280: 281: $NATS->DB->Free($r); 282: } 283: 284: else 285: { 286: echo "<b>Sorry - unknown display style type</b><br><br>"; 287: } 288: 289: mt_srand(microtime()*1000000); 290: if (mt_rand(0,100)==50) $track_if_enabled=true; 291: else $track_if_enabled=false; 292: 293: Screen_Footer($track_if_enabled); 294: ?> 295: