Viewing File server/web/monitor.php of 0.04.24a
|
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: ob_end_flush(); 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: if ($style=="standard") 93: { 94: 95: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 96: $r=$NATS->DB->Query($q); 97: 98: echo "<table border=0>"; 99: $a=0; 100: while ($row=$NATS->DB->Fetch_Array($r)) 101: { 102: if ($a==0) echo "<tr>"; 103: echo "<td>"; 104: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 105: echo "</td>"; 106: $a++; 107: if ($a==2) 108: { 109: $a=0; 110: echo "</tr>"; 111: } 112: } 113: if ($a>0) echo "</tr>"; 114: echo "</table>"; 115: 116: 117: $NATS->DB->Free($r); 118: 119: echo "<br><br>"; 120: 121: $q="SELECT * FROM fnnode ORDER BY alertlevel DESC, weight ASC"; 122: $r=$NATS->DB->Query($q); 123: 124: echo "<table border=0>"; 125: $a=0; 126: while ($row=$NATS->DB->Fetch_Array($r)) 127: { 128: if ($a==0) echo "<tr>"; 129: echo "<td>"; 130: np_tiny($row['nodeid'],true,$row['nodename']); 131: echo "</td>"; 132: $a++; 133: if ($a==5) 134: { 135: $a=0; 136: echo "</tr>"; 137: } 138: } 139: if ($a>0) echo "</tr>"; 140: echo "</table>"; 141: $NATS->DB->Free($r); 142: } 143: 144: else if ($style=="alerting") 145: { 146: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 147: $r=$NATS->DB->Query($q); 148: 149: echo "<table border=0>"; 150: $a=0; 151: while ($row=$NATS->DB->Fetch_Array($r)) 152: { 153: if ($NATS->GroupAlertLevel($row['groupid'])>0) 154: { 155: if ($a==0) echo "<tr>"; 156: echo "<td>"; 157: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 158: echo "</td>"; 159: $a++; 160: if ($a==2) 161: { 162: $a=0; 163: echo "</tr>"; 164: } 165: } 166: } 167: if ($a>0) echo "</tr>"; 168: echo "</table>"; 169: 170: 171: $NATS->DB->Free($r); 172: 173: echo "<br><br>"; 174: 175: $q="SELECT * FROM fnnode WHERE alertlevel!=0 ORDER BY alertlevel DESC, weight ASC"; 176: $r=$NATS->DB->Query($q); 177: 178: echo "<table border=0>"; 179: $a=0; 180: while ($row=$NATS->DB->Fetch_Array($r)) 181: { 182: if ($a==0) echo "<tr>"; 183: echo "<td>"; 184: np_tiny($row['nodeid'],true,$row['nodename']); 185: echo "</td>"; 186: $a++; 187: if ($a==5) 188: { 189: $a=0; 190: echo "</tr>"; 191: } 192: } 193: if ($a>0) echo "</tr>"; 194: echo "</table>"; 195: $NATS->DB->Free($r); 196: } 197: 198: else if ($style=="groups") 199: { 200: $q="SELECT * FROM fngroup ORDER BY weight ASC"; 201: $r=$NATS->DB->Query($q); 202: 203: echo "<table border=0>"; 204: $a=0; 205: while ($row=$NATS->DB->Fetch_Array($r)) 206: { 207: if ($a==0) echo "<tr>"; 208: echo "<td>"; 209: ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']); 210: echo "</td>"; 211: $a++; 212: if ($a==2) 213: { 214: $a=0; 215: echo "</tr>"; 216: } 217: } 218: if ($a>0) echo "</tr>"; 219: echo "</table>"; 220: 221: 222: $NATS->DB->Free($r); 223: } 224: 225: else if ($style=="nodes") 226: { 227: $q="SELECT * FROM fnnode ORDER BY alertlevel DESC, weight ASC"; 228: $r=$NATS->DB->Query($q); 229: 230: echo "<table border=0>"; 231: $a=0; 232: while ($row=$NATS->DB->Fetch_Array($r)) 233: { 234: if ($a==0) echo "<tr>"; 235: echo "<td>"; 236: np_big($row['nodeid'],$row['nodename'],$row['nodedesc'],$row['nodeicon']); 237: echo "</td>"; 238: $a++; 239: if ($a==2) 240: { 241: $a=0; 242: echo "</tr>"; 243: } 244: } 245: if ($a>0) echo "</tr>"; 246: echo "</table>"; 247: 248: 249: $NATS->DB->Free($r); 250: } 251: 252: else 253: { 254: echo "<b>Sorry - unknown display style type</b><br><br>"; 255: } 256: 257: 258: 259: Screen_Footer(); 260: ?> 261: