Project

General

Profile

Download (20.8 KB) Statistics
| Branch: | Tag: | Revision:
1 37285f69 Scott Ullrich
<?php
2
/* $Id$ */
3
/*
4
	status_rrd_graph.php
5
	Part of pfSense
6 6216690b smos
	Copyright (C) 2007 Seth Mos <seth.mos@dds.nl>
7 37285f69 Scott Ullrich
	All rights reserved.
8
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30 1d333258 Scott Ullrich
/*	
31
	pfSense_MODULE:	system
32
*/
33 37285f69 Scott Ullrich
34 6b07c15a Matthew Grooms
##|+PRIV
35
##|*IDENT=page-status-rrdgraphs
36
##|*NAME=Status: RRD Graphs page
37
##|*DESCR=Allow access to the 'Status: RRD Graphs' page.
38
##|*MATCH=status_rrd_graph.php*
39
##|-PRIV
40
41 37285f69 Scott Ullrich
require("guiconfig.inc");
42 5208e648 Ermal Lu?i
require_once("filter.inc");
43
require("shaper.inc");
44 483e6de8 Scott Ullrich
require_once("rrd.inc");
45 37285f69 Scott Ullrich
46 70281b3a Seth Mos
/* if the rrd graphs are not enabled redirect to settings page */
47
if(! isset($config['rrd']['enable'])) {
48
	header("Location: status_rrd_graph_settings.php");
49
}
50
51 329bb764 Seth Mos
$rrddbpath = "/var/db/rrd/";
52 002bc4ab smos
chdir($rrddbpath);
53
$databases = glob("*.rrd");
54
55 329bb764 Seth Mos
56 89d25faf Seth Mos
if ($_GET['cat']) {
57 034f08e7 Scott Ullrich
	$curcat = htmlspecialchars($_GET['cat']);
58 37285f69 Scott Ullrich
} else {
59 69487053 Seth Mos
	if(! empty($config['rrd']['category'])) {
60
		$curcat = $config['rrd']['category'];
61
	} else {
62
		$curcat = "system";
63
	}
64 89d25faf Seth Mos
}
65
66 7d906758 smos
if ($_GET['period']) {
67
	$curperiod = $_GET['period'];
68
} else {
69 97acf646 Erik Fonnesbeck
	if(! empty($config['rrd']['period'])) {
70
		$curperiod = $config['rrd']['period'];
71
	} else {
72
		$curperiod = "absolute";
73
	}
74 7d906758 smos
}
75
76 89d25faf Seth Mos
if ($_GET['option']) {
77
	$curoption = $_GET['option'];
78
} else {
79 329bb764 Seth Mos
	switch($curcat) {
80
		case "system":
81
			$curoption = "processor";
82
			break;
83
		case "queues":
84
			$curoption = "queues";
85
			break;
86
		case "queuedrops":
87
			$curoption = "queuedrops";
88 7432ce7b Seth Mos
			break;
89
		case "quality":
90
			foreach($databases as $database) {
91
				if(preg_match("/[-]quality\.rrd/i", $database)) {
92
					/* pick off the 1st database we find that matches the quality graph */
93
					$name = explode("-", $database);
94
					$curoption = "$name[0]";
95
					continue 2;
96
				}
97
			}
98
		case "wireless":
99
			foreach($databases as $database) {
100
				if(preg_match("/[-]wireless\.rrd/i", $database)) {
101
					/* pick off the 1st database we find that matches the wireless graph */
102
					$name = explode("-", $database);
103
					$curoption = "$name[0]";
104
					continue 2;
105
				}
106
			}
107
		case "cellular":
108
			foreach($databases as $database) {
109
				if(preg_match("/[-]cellular\.rrd/i", $database)) {
110
					/* pick off the 1st database we find that matches the celullar graph */
111
					$name = explode("-", $database);
112
					$curoption = "$name[0]";
113
					continue 2;
114
				}
115 329bb764 Seth Mos
			}
116 edd2d8b7 smos
		case "vpnusers":
117 6b0c5ae6 smos
			foreach($databases as $database) {
118 edd2d8b7 smos
				if(preg_match("/[-]vpnusers\.rrd/i", $database)) {
119 6b0c5ae6 smos
					/* pick off the 1st database we find that matches the VPN graphs */
120
					$name = explode("-", $database);
121
					$curoption = "$name[0]";
122
					continue 2;
123
				}
124
			}
125 20413b72 Warren Baker
		case "captiveportal":
126
			$curoption = "allgraphs";
127
			break;
128 329bb764 Seth Mos
		default:
129
			$curoption = "wan";
130
			break;
131 89d25faf Seth Mos
	}
132 37285f69 Scott Ullrich
}
133
134 6b0c5ae6 smos
$now = time();
135 47e68f48 smos
if($curcat == "custom") {
136
	if (is_numeric($_GET['start'])) {
137
			if($start < ($now - (3600 * 24 * 365 * 5))) {
138 c7cfbbd8 smos
					$start = $now - (8 * 3600);
139 47e68f48 smos
			}
140
			$start = $_GET['start'];
141
	} else {
142 c7cfbbd8 smos
			$start = $now - (8 * 3600);
143 47e68f48 smos
	}
144
}
145
146
if (is_numeric($_GET['end'])) {
147
        $end = $_GET['end'];
148
} else {
149
        $end = $now;
150
}
151
152
/* this should never happen */
153
if($end < $start) {
154 c7cfbbd8 smos
	log_error("start $start is smaller than end $end");
155 47e68f48 smos
        $end = $now;
156
}
157
158
$seconds = $end - $start;
159 5d7791a2 Scott Ullrich
160
$styles = array('inverse' => gettext('Inverse'),
161
		'absolute' => gettext('Absolute'));
162
163
// Set default and override later
164
$curstyle = "inverse";
165
166 6ab7ae50 Seth Mos
if ($_GET['style']) {
167 5d7791a2 Scott Ullrich
	foreach($styles as $style) 
168 4ec48253 Scott Ullrich
		if(strtoupper($style) == strtoupper($_GET['style'])) 
169 5d7791a2 Scott Ullrich
			$curstyle = $_GET['style'];
170 37285f69 Scott Ullrich
} else {
171 69487053 Seth Mos
	if(! empty($config['rrd']['style'])) {
172
		$curstyle = $config['rrd']['style'];
173
	} else {
174
		$curstyle = "inverse";
175
	}
176 37285f69 Scott Ullrich
}
177
178 329bb764 Seth Mos
/* sort names reverse so WAN comes first */
179 6ab7ae50 Seth Mos
rsort($databases);
180 37285f69 Scott Ullrich
181 9850b625 Seth Mos
/* these boilerplate databases are required for the other menu choices */
182
$dbheader = array("allgraphs-traffic.rrd",
183
		"allgraphs-quality.rrd",
184 2f80d451 Seth Mos
		"allgraphs-wireless.rrd",
185 ec51a222 thompsa
		"allgraphs-cellular.rrd",
186 edd2d8b7 smos
		"allgraphs-vpnusers.rrd",
187 20413b72 Warren Baker
		"captiveportal-allgraphs.rrd",
188 9850b625 Seth Mos
		"allgraphs-packets.rrd",
189
		"system-allgraphs.rrd",
190 e3d7c123 Seth Mos
		"system-throughput.rrd",
191 9850b625 Seth Mos
		"outbound-quality.rrd",
192
		"outbound-packets.rrd",
193
		"outbound-traffic.rrd");
194
195 9cd5e6f5 Erik Fonnesbeck
/* additional menu choices for the custom tab */
196
$dbheader_custom = array("system-throughput.rrd");
197
198 7432ce7b Seth Mos
foreach($databases as $database) {
199 edd2d8b7 smos
	if(stristr($database, "-wireless")) {
200 7432ce7b Seth Mos
		$wireless = true;
201
	}
202 edd2d8b7 smos
	if(stristr($database, "-queues")) {
203 7432ce7b Seth Mos
		$queues = true;
204
	}
205 17a71003 Ermal
	if(stristr($database, "-cellular") && !empty($config['ppps'])) {
206 7432ce7b Seth Mos
		$cellular = true;
207
	}
208 edd2d8b7 smos
	if(stristr($database, "-vpnusers")) {
209
		$vpnusers = true;
210 6b0c5ae6 smos
	}
211 20413b72 Warren Baker
	if(stristr($database, "captiveportal-") && isset($config['captiveportal']['enable'])) {
212
		$captiveportal = true;
213
	}
214 7432ce7b Seth Mos
}
215 9850b625 Seth Mos
/* append the existing array to the header */
216 a927edff Seth Mos
$ui_databases = array_merge($dbheader, $databases);
217 9cd5e6f5 Erik Fonnesbeck
$custom_databases = array_merge($dbheader_custom, $databases);
218 9850b625 Seth Mos
219 c7cfbbd8 smos
$graphs = array("8hour", "day", "week", "month", "quarter", "year", "4year");
220 97acf646 Erik Fonnesbeck
$periods = array("absolute" => gettext("Absolute Timespans"), "current" => gettext("Current Period"), "previous" => gettext("Previous Period"));
221
$graph_length = array(
222
	"8hour" => 28800,
223
	"day" => 86400,
224
	"week" => 604800,
225
	"month" => 2764800,
226
	"quarter" => 8035200,
227
	"year" => 31622400,
228
	"4year" => 126489600);
229 6ab7ae50 Seth Mos
230 1d80829e Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("RRD Graphs"));
231 89d25faf Seth Mos
include("head.inc");
232 6ab7ae50 Seth Mos
233 7d906758 smos
function get_dates($curperiod, $graph) {
234 97acf646 Erik Fonnesbeck
	global $graph_length;
235 7d906758 smos
	$now = time();
236
	$end = $now;
237
238 97acf646 Erik Fonnesbeck
	if($curperiod == "absolute") {
239
		$start = $end - $graph_length[$graph];
240
	} else {
241
		$curyear = date('Y', $now);
242
		$curmonth = date('m', $now);
243
		$curweek = date('W', $now);
244
		$curweekday = date('N', $now) - 1; // We want to start on monday
245
		$curday = date('d', $now);
246
		$curhour = date('G', $now);
247 c7cfbbd8 smos
248 97acf646 Erik Fonnesbeck
		switch($curperiod) {
249
			case "previous":
250
				$offset = -1;
251
				break;
252
			default:
253
				$offset = 0;
254
		}
255
		switch($graph) {
256
			case "8hour":
257
				if($curhour < 24)
258
					$starthour = 16;
259
				if($curhour < 16)
260
					$starthour = 8;
261
				if($curhour < 8)
262
					$starthour = 0;
263
264
				switch($offset) {
265
					case 0:
266
						$houroffset = $starthour;
267
						break;
268
					default:
269
						$houroffset = $starthour + ($offset * 8);
270
						break;
271
				}
272
				$start = mktime($houroffset, 0, 0, $curmonth, $curday, $curyear);
273
				if($offset != 0) {
274
					$end = mktime(($houroffset + 8), 0, 0, $curmonth, $curday, $curyear);
275
				}
276
				break;
277
			case "day":
278
				$start = mktime(0, 0, 0, $curmonth, ($curday + $offset), $curyear);
279
				if($offset != 0)
280
					$end = mktime(0, 0, 0, $curmonth, (($curday + $offset) + 1), $curyear);
281
				break;
282
			case "week":
283
				switch($offset) {
284
					case 0:
285
						$weekoffset = 0;
286
						break;
287
					default:
288
						$weekoffset = ($offset * 7) - 7;
289
						break;
290
				}
291
				$start = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset), $curyear);
292
				if($offset != 0)
293
					$end = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset + 7), $curyear);
294
				break;
295
			case "month":
296
				$start = mktime(0, 0, 0, ($curmonth + $offset), 0, $curyear);
297
				if($offset != 0)
298
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
299
				break;
300
			case "quarter":
301
				$start = mktime(0, 0, 0, (($curmonth - 2) + $offset), 0, $curyear);
302
				if($offset != 0)
303
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
304
				break;
305
			case "year":
306
				$start = mktime(0, 0, 0, 1, 0, ($curyear + $offset));
307
				if($offset != 0)
308
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
309
				break;
310
			case "4year":
311
				$start = mktime(0, 0, 0, 1, 0, (($curyear - 3) + $offset));
312
				if($offset != 0)
313
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
314
				break;
315
		}
316 7d906758 smos
	}
317 6a8cf738 smos
	// echo "start $start ". date('l jS \of F Y h:i:s A', $start) .", end $end ". date('l jS \of F Y h:i:s A', $end) ."<br>";
318 7d906758 smos
	$dates = array();
319
	$dates['start'] = $start;
320
	$dates['end'] = $end;
321
	return $dates;
322
}
323
324 6ab7ae50 Seth Mos
?>
325 37285f69 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
326
<?php include("fbegin.inc"); ?>
327 89d25faf Seth Mos
<table width="100%" border="0" cellpadding="0" cellspacing="0">
328
        <tr>
329
                <td>
330
			<form name="form1" action="status_rrd_graph.php" method="get">
331
			<input type="hidden" name="cat" value="<?php echo "$curcat"; ?>">
332
			<?php
333
			        $tab_array = array();
334
				if($curcat == "system") { $tabactive = True; } else { $tabactive = False; }
335 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system");
336 89d25faf Seth Mos
				if($curcat == "traffic") { $tabactive = True; } else { $tabactive = False; }
337 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic");
338 89d25faf Seth Mos
				if($curcat == "packets") { $tabactive = True; } else { $tabactive = False; }
339 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets");
340 89d25faf Seth Mos
				if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; }
341 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality");
342 7432ce7b Seth Mos
				if($queues) {
343
					if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; }
344 d9a0c4b8 Vinicius Coque
						$tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues");
345 7432ce7b Seth Mos
					if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; }
346 d9a0c4b8 Vinicius Coque
						$tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops");
347 7432ce7b Seth Mos
				}
348
				if($wireless) {
349
					if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; }
350 4dea46ee Rafael Lucas
				        $tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless");
351 7432ce7b Seth Mos
				}
352
				if($cellular) {
353
					if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; }
354 4dea46ee Rafael Lucas
				        $tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular");
355 7432ce7b Seth Mos
				}
356 edd2d8b7 smos
				if($vpnusers) {
357
					if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; }
358
				        $tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers");
359 6b0c5ae6 smos
				}
360 20413b72 Warren Baker
				if($captiveportal) {
361
					if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; }
362
				        $tab_array[] = array("Captive Portal", $tabactive, "status_rrd_graph.php?cat=captiveportal");
363
				}
364 47e68f48 smos
				if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; }
365 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom");
366 69487053 Seth Mos
				if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; }
367 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php");
368 89d25faf Seth Mos
			        display_top_tabs($tab_array);
369
			?>
370
                </td>
371
        </tr>
372
        <tr>
373
                <td>
374
                        <div id="mainarea">
375
                        <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
376
                                <tr>
377
                                        <td colspan="2" class="list"><p><b><?=gettext("Note: Change of color and/or style may not take effect until the next refresh");?></b></p></td>
378
				</tr>
379
				<tr>
380
                                        <td colspan="2" class="list">
381 3e6ec5df Renato Botelho
					<?=gettext("Graphs:");?>
382 89d25faf Seth Mos
					<select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
383
					<?php
384
385 47e68f48 smos
					if($curcat == "custom") {
386 9cd5e6f5 Erik Fonnesbeck
						foreach ($custom_databases as $db => $database) {
387 cfbfd941 smos
							$optionc = explode("-", $database);
388 47e68f48 smos
							$search = array("-", ".rrd", $optionc);
389
							$replace = array(" :: ", "", $friendly);
390
							echo "<option value=\"{$database}\"";
391
							$prettyprint = ucwords(str_replace($search, $replace, $database));
392
							if($curoption == $database) {
393 1d80829e Carlos Eduardo Ramos
								echo " selected";
394 47e68f48 smos
							}
395
							echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
396
						}
397
					}
398 a927edff Seth Mos
					foreach ($ui_databases as $db => $database) {
399 2ab73e04 Seth Mos
						if(! preg_match("/($curcat)/i", $database)) {
400 89d25faf Seth Mos
							continue;
401
						}
402 cfbfd941 smos
						$optionc = explode("-", $database);
403 89d25faf Seth Mos
						$search = array("-", ".rrd", $optionc);
404 35551994 Seth Mos
						$replace = array(" :: ", "", $friendly);
405 47e68f48 smos
406 9850b625 Seth Mos
						switch($curcat) {
407 20413b72 Warren Baker
							case "captiveportal":
408
								$optionc = str_replace($search, $replace, $optionc[1]);
409
								echo "<option value=\"$optionc\"";
410
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
411
								break;
412 9850b625 Seth Mos
							case "system":
413 85a4aab6 Erik Fonnesbeck
								$optionc = str_replace($search, $replace, $optionc[1]);
414
								echo "<option value=\"$optionc\"";
415
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
416 9850b625 Seth Mos
								break;
417
							default:
418
								/* Deduce a interface if possible and use the description */
419
								$optionc = "$optionc[0]";
420
								$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc));
421 d9699f96 Seth Mos
								if(empty($friendly)) {
422
									$friendly = $optionc;
423
								}
424 9850b625 Seth Mos
								$search = array("-", ".rrd", $optionc);
425
								$replace = array(" :: ", "", $friendly);
426
								echo "<option value=\"$optionc\"";
427
								$prettyprint = ucwords(str_replace($search, $replace, $friendly));
428
						}
429
						if($curoption == $optionc) {
430 1d80829e Carlos Eduardo Ramos
							echo " selected";
431 89d25faf Seth Mos
						}
432
						echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
433
					}
434
435
					?>
436
					</select>
437
438 3e6ec5df Renato Botelho
					<?=gettext("Style:");?>
439 89d25faf Seth Mos
					<select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
440
					<?php
441
					foreach ($styles as $style => $styled) {
442
						echo "<option value=\"$style\"";
443
						if ($style == $curstyle) echo " selected";
444
						echo ">" . htmlspecialchars($styled) . "</option>\n";
445
					}
446
					?>
447 7d906758 smos
					</select>
448
					
449 e4b57d26 Renato Botelho
					<?php
450 47e68f48 smos
					if($curcat <> "custom") {
451
					?>
452 3e6ec5df Renato Botelho
						<?=gettext("Period:");?>
453 47e68f48 smos
						<select name="period" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
454
						<?php
455
						foreach ($periods as $period => $value) {
456
							echo "<option value=\"$period\"";
457 1d80829e Carlos Eduardo Ramos
							if ($period == $curperiod) echo " selected";
458 47e68f48 smos
							echo ">" . htmlspecialchars($value) . "</option>\n";
459
						}
460 7d906758 smos
					}
461
					?>
462 89d25faf Seth Mos
					</select>
463
					<?php
464
465 47e68f48 smos
					if($curcat == "custom") {
466 6b0c5ae6 smos
						?>
467
						<?=gettext("Start:");?>
468
						<input type="text" name="start" class="formfldunknown" length="32" value="<?php echo $start;?>">
469
						<?=gettext("End:");?>
470 22aaee7d smos
						<input type="text" name="end" class="formfldunknown" length="32" value="<?php echo $end;?>">
471 b8219006 Carlos Eduardo Ramos
						<input type="submit" name="Submit" value="<?=gettext("Go"); ?>">
472 3e6ec5df Renato Botelho
						<?php
473 6b0c5ae6 smos
						$curdatabase = $curoption;
474
						$graph = "custom-$curdatabase";
475 9cd5e6f5 Erik Fonnesbeck
						if(in_array($curdatabase, $custom_databases)) {
476 6b0c5ae6 smos
							echo "<tr><td colspan=2 class=\"list\">\n";
477
							echo "<IMG BORDER='0' name='{$graph}-{$curoption}-{$curdatabase}' ";
478
							echo "id='{$graph}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
479
							echo "SRC=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
480
							echo "<br /><hr><br />\n";								
481
							echo "</td></tr>\n";
482
						}
483
					} else {
484
						foreach($graphs as $graph) {
485
							/* check which databases are valid for our category */
486
							foreach($ui_databases as $curdatabase) {
487
								if(! preg_match("/($curcat)/i", $curdatabase)) {
488
									continue;
489
								}
490 cfbfd941 smos
								$optionc = explode("-", $curdatabase);
491 6b0c5ae6 smos
								$search = array("-", ".rrd", $optionc);
492
								$replace = array(" :: ", "", $friendly);
493
								switch($curoption) {
494
									case "outbound":
495 2103b252 Erik Fonnesbeck
										/* make sure we do not show the placeholder databases in the outbound view */
496
										if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
497
											continue 2;
498
										}
499 6b0c5ae6 smos
										/* only show interfaces with a gateway */
500
										$optionc = "$optionc[0]";
501
										if(!interface_has_gateway($optionc)) {
502 2103b252 Erik Fonnesbeck
											if(!isset($gateways_arr)) {
503
												if(preg_match("/quality/i", $curdatabase))
504
													$gateways_arr = return_gateways_array();
505
												else
506
													$gateways_arr = array();
507
											}
508 44aef543 Erik Fonnesbeck
											$found_gateway = false;
509
											foreach ($gateways_arr as $gw) {
510
												if ($gw['name'] == $optionc) {
511
													$found_gateway = true;
512
													break;
513
												}
514
											}
515
											if(!$found_gateway) {
516 6b0c5ae6 smos
												continue 2;
517
											}
518
										}
519 44aef543 Erik Fonnesbeck
										if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
520 a927edff Seth Mos
											continue 2;
521
										}
522 6b0c5ae6 smos
										break;
523
									case "allgraphs":
524
										/* make sure we do not show the placeholder databases in the all view */
525
										if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
526
											continue 2;
527
										}
528
										break;
529
									default:
530
										/* just use the name here */
531 44aef543 Erik Fonnesbeck
										if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
532 6b0c5ae6 smos
											continue 2;
533
										}
534
								}
535 9cd5e6f5 Erik Fonnesbeck
								if(in_array($curdatabase, $ui_databases)) {
536 6b0c5ae6 smos
									$dates = get_dates($curperiod, $graph);
537
									$start = $dates['start'];
538
									$end = $dates['end'];
539
									echo "<tr><td colspan=2 class=\"list\">\n";
540
									echo "<IMG BORDER='0' name='{$graph}-{$curoption}-{$curdatabase}' ";
541
									echo "id='{$graph}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
542
									echo "SRC=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
543
									echo "<br /><hr><br />\n";								
544
									echo "</td></tr>\n";
545
								}
546 89d25faf Seth Mos
							}
547
						}
548
					}
549
					?>
550
					</td>
551
				</tr>
552
				<tr>
553
					<td colspan=2 class="list">
554
					<script language="javascript">
555
						function update_graph_images() {
556
							//alert('updating');
557
							var randomid = Math.floor(Math.random()*11);
558
							<?php
559 7d906758 smos
							foreach($graphs as $graph) {
560 683bf031 Seth Mos
								/* check which databases are valid for our category */
561 9cd5e6f5 Erik Fonnesbeck
								foreach($ui_databases as $curdatabase) {
562 683bf031 Seth Mos
									if(! stristr($curdatabase, $curcat)) {
563
										continue;
564
									}
565 cfbfd941 smos
									$optionc = explode("-", $curdatabase);
566 683bf031 Seth Mos
									$search = array("-", ".rrd", $optionc);
567
									$replace = array(" :: ", "", $friendly);
568
									switch($curoption) {
569
										case "outbound":
570 2103b252 Erik Fonnesbeck
											/* make sure we do not show the placeholder databases in the outbound view */
571
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
572
												continue 2;
573
											}
574
											/* only show interfaces with a gateway */
575 44aef543 Erik Fonnesbeck
											$optionc = "$optionc[0]";
576 2e76e612 Seth Mos
											if(!interface_has_gateway($optionc)) {
577 44aef543 Erik Fonnesbeck
												if(!isset($gateways_arr))
578 2103b252 Erik Fonnesbeck
													if(preg_match("/quality/i", $curdatabase))
579
														$gateways_arr = return_gateways_array();
580
													else
581
														$gateways_arr = array();
582 44aef543 Erik Fonnesbeck
												$found_gateway = false;
583
												foreach ($gateways_arr as $gw) {
584
													if ($gw['name'] == $optionc) {
585
														$found_gateway = true;
586
														break;
587
													}
588
												}
589
												if(!$found_gateway) {
590 683bf031 Seth Mos
													continue 2;
591 44aef543 Erik Fonnesbeck
												}
592
											}
593
											if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
594
												continue 2;
595 683bf031 Seth Mos
											}
596 9850b625 Seth Mos
											break;
597 683bf031 Seth Mos
										case "allgraphs":
598 9850b625 Seth Mos
											/* make sure we do not show the placeholder databases in the all view */
599
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
600
												continue 2;
601
											}
602
											break;
603 683bf031 Seth Mos
										default:
604
											/* just use the name here */
605 44aef543 Erik Fonnesbeck
											if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
606 683bf031 Seth Mos
												continue 2;
607
											}
608
									}
609 7d906758 smos
									$dates = get_dates($curperiod, $graph);
610
									$start = $dates['start'];
611 d60f510a smos
									if($curperiod == "current") {
612
										$end = $dates['end'];
613
									}
614 78d84a88 Vinicius Coque
									/* generate update events utilizing jQuery('') feature */
615 683bf031 Seth Mos
									echo "\n";
616 78d84a88 Vinicius Coque
									echo "\t\tjQuery('#{$graph}-{$curoption}-{$curdatabase}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n";
617 683bf031 Seth Mos
									}
618
								}
619 89d25faf Seth Mos
							?>
620
							window.setTimeout('update_graph_images()', 355000);
621
						}
622
						window.setTimeout('update_graph_images()', 355000);
623
					</script>
624
					</form>
625
					</td>
626
				</tr>
627
			</table>
628
		</div>
629
		</td>
630
	</tr>
631
</table>
632 37285f69 Scott Ullrich
633
<?php include("fend.inc"); ?>
634
</body>
635
</html>