File: 0.04.27a/server/web/monitor.php (View as HTML)

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