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