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