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

  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($NATS->Lang->Item("live.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($NATS->Lang->Item("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()"><?php echo $NATS->Lang->Item("mon.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 $monpopup=true;
 70: 
 71: if ($monpopup)
 72: {
 73: echo "<div class=\"monitor_popup\" id=\"popup_div\"></div>";
 74: echo "<script type=\"text/javascript\" src=\"js/monitor.popup.js\">\n";
 75: echo "</script>\n";
 76: }
 77: ?>
 78: 
 79: <script type="text/javascript">
 80: var dispOptions=new Array();
 81: var dispLink=new Array();
 82: 
 83: var optCount=0;
 84: dispOptions[optCount]='standard';
 85: dispLink[optCount++]='<?php echo $NATS->Lang->Item("mon.std"); ?>';
 86: dispOptions[optCount]='groups';
 87: dispLink[optCount++]='<?php echo $NATS->Lang->Item("mon.grp"); ?>';
 88: dispOptions[optCount]='nodes';
 89: dispLink[optCount++]='<?php echo $NATS->Lang->Item("mon.nodes"); ?>';
 90: dispOptions[optCount]='alerting';
 91: dispLink[optCount++]='<?php echo $NATS->Lang->Item("mon.alerting"); ?>';
 92: 
 93: function showMonitorViews()
 94: {
 95: var content='';
 96: for (var a=0; a<optCount; a++)
 97: 	{
 98: 	content=content+'<a href=monitor.php?style='+dispOptions[a]+'>';
 99: 	content=content+'<img src=images/monitor_thumb/'+dispOptions[a]+'.png border=0><br>'+dispLink[a]+'</a><br><br>';
100: 	}
101: content=content+'<a href="javascript:hideMonitorViews()"><?php echo $NATS->Lang->Item("mon.hide"); ?></a>';
102: document.getElementById('monitorviews_div').innerHTML=content;
103: }
104: 
105: function hideMonitorViews()
106: {
107: document.getElementById('monitorviews_div').innerHTML='<a href="javascript:showMonitorViews()"><?php echo $NATS->Lang->Item("mon.options"); ?></a>';
108: }
109: 
110: <?php
111:  if (isset($_REQUEST['showviewoption'])) echo "showMonitorViews();\n";
112: ?>
113: </script>
114: 
115: <?php
116: 
117: 
118: ob_end_flush();
119: 
120: if ($style=="standard")
121: {
122: 
123: $q="SELECT * FROM fngroup ORDER BY weight ASC";
124: $r=$NATS->DB->Query($q);
125: 
126: if ($NATS->DB->Num_Rows($r)>0)
127: 	{
128: 	echo "<table border=0>";
129: 	$a=0;
130: 	while ($row=$NATS->DB->Fetch_Array($r))
131: 		{
132: 		if ($a==0) echo "<tr>";
133: 		echo "<td>";
134: 		ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']);
135: 		echo "</td>";
136: 		$a++;
137: 		if ($a==2)
138: 			{
139: 			$a=0;
140: 			echo "</tr>";
141: 			}
142: 		}
143: 	if ($a>0) echo "</tr>";
144: 	echo "</table>";
145: 	echo "<br><br>";
146: 	}
147: 
148: 
149: $NATS->DB->Free($r);
150: 
151: 
152: $q="SELECT * FROM fnnode ORDER BY alertlevel DESC, 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 ($a==0) echo "<tr>";
160: 	echo "<td>";
161: 	np_tiny($row['nodeid'],true,$row['nodename'],$monpopup);
162: 	echo "</td>";
163: 	$a++;
164: 	if ($a==5)
165: 		{
166: 		$a=0;
167: 		echo "</tr>";
168: 		}
169: 	}
170: if ($a>0) echo "</tr>";
171: echo "</table>";
172: $NATS->DB->Free($r);
173: }
174: 
175: else if ($style=="alerting")
176: {
177: $q="SELECT * FROM fngroup ORDER BY 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 ($NATS->GroupAlertLevel($row['groupid'])>0)
185: 		{
186: 		if ($a==0) echo "<tr>";
187: 		echo "<td>";
188: 		ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon']);
189: 		echo "</td>";
190: 		$a++;
191: 		if ($a==2)
192: 			{
193: 			$a=0;
194: 			echo "</tr>";
195: 			}
196: 		}
197: 	}
198: if ($a>0) echo "</tr>";
199: echo "</table>";
200: 
201: 
202: $NATS->DB->Free($r);
203: 
204: echo "<br><br>";
205: 
206: $q="SELECT * FROM fnnode WHERE alertlevel!=0 ORDER BY alertlevel DESC, 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: 	np_tiny($row['nodeid'],true,$row['nodename'],$monpopup);
216: 	echo "</td>";
217: 	$a++;
218: 	if ($a==5)
219: 		{
220: 		$a=0;
221: 		echo "</tr>";
222: 		}
223: 	}
224: if ($a>0) echo "</tr>";
225: echo "</table>";
226: $NATS->DB->Free($r);
227: }
228: 
229: else if ($style=="groups")
230: {
231: $q="SELECT * FROM fngroup ORDER BY weight ASC";
232: $r=$NATS->DB->Query($q);
233: 
234: echo "<table border=0>";
235: $a=0;
236: while ($row=$NATS->DB->Fetch_Array($r))
237: 	{
238: 	if ($a==0) echo "<tr>";
239: 	echo "<td>";
240: 	ng_big($row['groupid'],$row['groupname'],$row['groupdesc'],$row['groupicon'],$monpopup);
241: 	echo "</td>";
242: 	$a++;
243: 	if ($a==2)
244: 		{
245: 		$a=0;
246: 		echo "</tr>";
247: 		}
248: 	}
249: if ($a>0) echo "</tr>";
250: echo "</table>";
251: 
252: 
253: $NATS->DB->Free($r);
254: }
255: 
256: else if ($style=="nodes")
257: {
258: $q="SELECT * FROM fnnode ORDER BY alertlevel DESC, weight ASC";
259: $r=$NATS->DB->Query($q);
260: 
261: echo "<table border=0>";
262: $a=0;
263: while ($row=$NATS->DB->Fetch_Array($r))
264: 	{
265: 	if ($a==0) echo "<tr>";
266: 	echo "<td>";
267: 	np_big($row['nodeid'],$row['nodename'],$row['nodedesc'],$row['nodeicon'],$monpopup);
268: 	echo "</td>";
269: 	$a++;
270: 	if ($a==2)
271: 		{
272: 		$a=0;
273: 		echo "</tr>";
274: 		}
275: 	}
276: if ($a>0) echo "</tr>";
277: echo "</table>";
278: 
279: 
280: $NATS->DB->Free($r);
281: }
282: 
283: else
284: {
285: echo "<b>Sorry - unknown display style type</b><br><br>";
286: }
287: 
288: mt_srand(microtime()*1000000);
289: if (mt_rand(0,100)==50) $track_if_enabled=true;
290: else $track_if_enabled=false;
291: 
292: Screen_Footer($track_if_enabled);
293: ?>
294: