Project

General

Profile

Download (20.6 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
					
160 6ab7ae50 Seth Mos
if ($_GET['style']) {
161
	$curstyle = $_GET['style'];
162 37285f69 Scott Ullrich
} else {
163 69487053 Seth Mos
	if(! empty($config['rrd']['style'])) {
164
		$curstyle = $config['rrd']['style'];
165
	} else {
166
		$curstyle = "inverse";
167
	}
168 37285f69 Scott Ullrich
}
169
170 329bb764 Seth Mos
/* sort names reverse so WAN comes first */
171 6ab7ae50 Seth Mos
rsort($databases);
172 37285f69 Scott Ullrich
173 9850b625 Seth Mos
/* these boilerplate databases are required for the other menu choices */
174
$dbheader = array("allgraphs-traffic.rrd",
175
		"allgraphs-quality.rrd",
176 2f80d451 Seth Mos
		"allgraphs-wireless.rrd",
177 ec51a222 thompsa
		"allgraphs-cellular.rrd",
178 edd2d8b7 smos
		"allgraphs-vpnusers.rrd",
179 20413b72 Warren Baker
		"captiveportal-allgraphs.rrd",
180 9850b625 Seth Mos
		"allgraphs-packets.rrd",
181
		"system-allgraphs.rrd",
182 e3d7c123 Seth Mos
		"system-throughput.rrd",
183 9850b625 Seth Mos
		"outbound-quality.rrd",
184
		"outbound-packets.rrd",
185
		"outbound-traffic.rrd");
186
187 9cd5e6f5 Erik Fonnesbeck
/* additional menu choices for the custom tab */
188
$dbheader_custom = array("system-throughput.rrd");
189
190 7432ce7b Seth Mos
foreach($databases as $database) {
191 edd2d8b7 smos
	if(stristr($database, "-wireless")) {
192 7432ce7b Seth Mos
		$wireless = true;
193
	}
194 edd2d8b7 smos
	if(stristr($database, "-queues")) {
195 7432ce7b Seth Mos
		$queues = true;
196
	}
197 17a71003 Ermal
	if(stristr($database, "-cellular") && !empty($config['ppps'])) {
198 7432ce7b Seth Mos
		$cellular = true;
199
	}
200 edd2d8b7 smos
	if(stristr($database, "-vpnusers")) {
201
		$vpnusers = true;
202 6b0c5ae6 smos
	}
203 20413b72 Warren Baker
	if(stristr($database, "captiveportal-") && isset($config['captiveportal']['enable'])) {
204
		$captiveportal = true;
205
	}
206 7432ce7b Seth Mos
}
207 9850b625 Seth Mos
/* append the existing array to the header */
208 a927edff Seth Mos
$ui_databases = array_merge($dbheader, $databases);
209 9cd5e6f5 Erik Fonnesbeck
$custom_databases = array_merge($dbheader_custom, $databases);
210 9850b625 Seth Mos
211 3dbd3be9 Carlos Eduardo Ramos
$styles = array('inverse' => gettext('Inverse'),
212
		'absolute' => gettext('Absolute'));
213 c7cfbbd8 smos
$graphs = array("8hour", "day", "week", "month", "quarter", "year", "4year");
214 97acf646 Erik Fonnesbeck
$periods = array("absolute" => gettext("Absolute Timespans"), "current" => gettext("Current Period"), "previous" => gettext("Previous Period"));
215
$graph_length = array(
216
	"8hour" => 28800,
217
	"day" => 86400,
218
	"week" => 604800,
219
	"month" => 2764800,
220
	"quarter" => 8035200,
221
	"year" => 31622400,
222
	"4year" => 126489600);
223 6ab7ae50 Seth Mos
224 1d80829e Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("RRD Graphs"));
225 89d25faf Seth Mos
include("head.inc");
226 6ab7ae50 Seth Mos
227 7d906758 smos
function get_dates($curperiod, $graph) {
228 97acf646 Erik Fonnesbeck
	global $graph_length;
229 7d906758 smos
	$now = time();
230
	$end = $now;
231
232 97acf646 Erik Fonnesbeck
	if($curperiod == "absolute") {
233
		$start = $end - $graph_length[$graph];
234
	} else {
235
		$curyear = date('Y', $now);
236
		$curmonth = date('m', $now);
237
		$curweek = date('W', $now);
238
		$curweekday = date('N', $now) - 1; // We want to start on monday
239
		$curday = date('d', $now);
240
		$curhour = date('G', $now);
241 c7cfbbd8 smos
242 97acf646 Erik Fonnesbeck
		switch($curperiod) {
243
			case "previous":
244
				$offset = -1;
245
				break;
246
			default:
247
				$offset = 0;
248
		}
249
		switch($graph) {
250
			case "8hour":
251
				if($curhour < 24)
252
					$starthour = 16;
253
				if($curhour < 16)
254
					$starthour = 8;
255
				if($curhour < 8)
256
					$starthour = 0;
257
258
				switch($offset) {
259
					case 0:
260
						$houroffset = $starthour;
261
						break;
262
					default:
263
						$houroffset = $starthour + ($offset * 8);
264
						break;
265
				}
266
				$start = mktime($houroffset, 0, 0, $curmonth, $curday, $curyear);
267
				if($offset != 0) {
268
					$end = mktime(($houroffset + 8), 0, 0, $curmonth, $curday, $curyear);
269
				}
270
				break;
271
			case "day":
272
				$start = mktime(0, 0, 0, $curmonth, ($curday + $offset), $curyear);
273
				if($offset != 0)
274
					$end = mktime(0, 0, 0, $curmonth, (($curday + $offset) + 1), $curyear);
275
				break;
276
			case "week":
277
				switch($offset) {
278
					case 0:
279
						$weekoffset = 0;
280
						break;
281
					default:
282
						$weekoffset = ($offset * 7) - 7;
283
						break;
284
				}
285
				$start = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset), $curyear);
286
				if($offset != 0)
287
					$end = mktime(0, 0, 0, $curmonth, (($curday - $curweekday) + $weekoffset + 7), $curyear);
288
				break;
289
			case "month":
290
				$start = mktime(0, 0, 0, ($curmonth + $offset), 0, $curyear);
291
				if($offset != 0)
292
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
293
				break;
294
			case "quarter":
295
				$start = mktime(0, 0, 0, (($curmonth - 2) + $offset), 0, $curyear);
296
				if($offset != 0)
297
					$end = mktime(0, 0, 0, (($curmonth + $offset) + 1), 0, $curyear);
298
				break;
299
			case "year":
300
				$start = mktime(0, 0, 0, 1, 0, ($curyear + $offset));
301
				if($offset != 0)
302
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
303
				break;
304
			case "4year":
305
				$start = mktime(0, 0, 0, 1, 0, (($curyear - 3) + $offset));
306
				if($offset != 0)
307
					$end = mktime(0, 0, 0, 1, 0, (($curyear + $offset) +1));
308
				break;
309
		}
310 7d906758 smos
	}
311 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>";
312 7d906758 smos
	$dates = array();
313
	$dates['start'] = $start;
314
	$dates['end'] = $end;
315
	return $dates;
316
}
317
318 6ab7ae50 Seth Mos
?>
319 37285f69 Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
320
<?php include("fbegin.inc"); ?>
321 89d25faf Seth Mos
<table width="100%" border="0" cellpadding="0" cellspacing="0">
322
        <tr>
323
                <td>
324
			<form name="form1" action="status_rrd_graph.php" method="get">
325
			<input type="hidden" name="cat" value="<?php echo "$curcat"; ?>">
326
			<?php
327
			        $tab_array = array();
328
				if($curcat == "system") { $tabactive = True; } else { $tabactive = False; }
329 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("System"), $tabactive, "status_rrd_graph.php?cat=system");
330 89d25faf Seth Mos
				if($curcat == "traffic") { $tabactive = True; } else { $tabactive = False; }
331 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Traffic"), $tabactive, "status_rrd_graph.php?cat=traffic");
332 89d25faf Seth Mos
				if($curcat == "packets") { $tabactive = True; } else { $tabactive = False; }
333 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Packets"), $tabactive, "status_rrd_graph.php?cat=packets");
334 89d25faf Seth Mos
				if($curcat == "quality") { $tabactive = True; } else { $tabactive = False; }
335 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Quality"), $tabactive, "status_rrd_graph.php?cat=quality");
336 7432ce7b Seth Mos
				if($queues) {
337
					if($curcat == "queues") { $tabactive = True; } else { $tabactive = False; }
338 d9a0c4b8 Vinicius Coque
						$tab_array[] = array(gettext("Queues"), $tabactive, "status_rrd_graph.php?cat=queues");
339 7432ce7b Seth Mos
					if($curcat == "queuedrops") { $tabactive = True; } else { $tabactive = False; }
340 d9a0c4b8 Vinicius Coque
						$tab_array[] = array(gettext("QueueDrops"), $tabactive, "status_rrd_graph.php?cat=queuedrops");
341 7432ce7b Seth Mos
				}
342
				if($wireless) {
343
					if($curcat == "wireless") { $tabactive = True; } else { $tabactive = False; }
344 4dea46ee Rafael Lucas
				        $tab_array[] = array(gettext("Wireless"), $tabactive, "status_rrd_graph.php?cat=wireless");
345 7432ce7b Seth Mos
				}
346
				if($cellular) {
347
					if($curcat == "cellular") { $tabactive = True; } else { $tabactive = False; }
348 4dea46ee Rafael Lucas
				        $tab_array[] = array(gettext("Cellular"), $tabactive, "status_rrd_graph.php?cat=cellular");
349 7432ce7b Seth Mos
				}
350 edd2d8b7 smos
				if($vpnusers) {
351
					if($curcat == "vpnusers") { $tabactive = True; } else { $tabactive = False; }
352
				        $tab_array[] = array("VPN", $tabactive, "status_rrd_graph.php?cat=vpnusers");
353 6b0c5ae6 smos
				}
354 20413b72 Warren Baker
				if($captiveportal) {
355
					if($curcat == "captiveportal") { $tabactive = True; } else { $tabactive = False; }
356
				        $tab_array[] = array("Captive Portal", $tabactive, "status_rrd_graph.php?cat=captiveportal");
357
				}
358 47e68f48 smos
				if($curcat == "custom") { $tabactive = True; } else { $tabactive = False; }
359 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Custom"), $tabactive, "status_rrd_graph.php?cat=custom");
360 69487053 Seth Mos
				if($curcat == "settings") { $tabactive = True; } else { $tabactive = False; }
361 4dea46ee Rafael Lucas
			        $tab_array[] = array(gettext("Settings"), $tabactive, "status_rrd_graph_settings.php");
362 89d25faf Seth Mos
			        display_top_tabs($tab_array);
363
			?>
364
                </td>
365
        </tr>
366
        <tr>
367
                <td>
368
                        <div id="mainarea">
369
                        <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
370
                                <tr>
371
                                        <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>
372
				</tr>
373
				<tr>
374
                                        <td colspan="2" class="list">
375 3e6ec5df Renato Botelho
					<?=gettext("Graphs:");?>
376 89d25faf Seth Mos
					<select name="option" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
377
					<?php
378
379 47e68f48 smos
					if($curcat == "custom") {
380 9cd5e6f5 Erik Fonnesbeck
						foreach ($custom_databases as $db => $database) {
381 47e68f48 smos
							$optionc = split("-", $database);
382
							$search = array("-", ".rrd", $optionc);
383
							$replace = array(" :: ", "", $friendly);
384
							echo "<option value=\"{$database}\"";
385
							$prettyprint = ucwords(str_replace($search, $replace, $database));
386
							if($curoption == $database) {
387 1d80829e Carlos Eduardo Ramos
								echo " selected";
388 47e68f48 smos
							}
389
							echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
390
						}
391
					}
392 a927edff Seth Mos
					foreach ($ui_databases as $db => $database) {
393 2ab73e04 Seth Mos
						if(! preg_match("/($curcat)/i", $database)) {
394 89d25faf Seth Mos
							continue;
395
						}
396
						$optionc = split("-", $database);
397
						$search = array("-", ".rrd", $optionc);
398 35551994 Seth Mos
						$replace = array(" :: ", "", $friendly);
399 47e68f48 smos
400 9850b625 Seth Mos
						switch($curcat) {
401 20413b72 Warren Baker
							case "captiveportal":
402
								$optionc = str_replace($search, $replace, $optionc[1]);
403
								echo "<option value=\"$optionc\"";
404
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
405
								break;
406 9850b625 Seth Mos
							case "system":
407 85a4aab6 Erik Fonnesbeck
								$optionc = str_replace($search, $replace, $optionc[1]);
408
								echo "<option value=\"$optionc\"";
409
								$prettyprint = ucwords(str_replace($search, $replace, $optionc));
410 9850b625 Seth Mos
								break;
411
							default:
412
								/* Deduce a interface if possible and use the description */
413
								$optionc = "$optionc[0]";
414
								$friendly = convert_friendly_interface_to_friendly_descr(strtolower($optionc));
415 d9699f96 Seth Mos
								if(empty($friendly)) {
416
									$friendly = $optionc;
417
								}
418 9850b625 Seth Mos
								$search = array("-", ".rrd", $optionc);
419
								$replace = array(" :: ", "", $friendly);
420
								echo "<option value=\"$optionc\"";
421
								$prettyprint = ucwords(str_replace($search, $replace, $friendly));
422
						}
423
						if($curoption == $optionc) {
424 1d80829e Carlos Eduardo Ramos
							echo " selected";
425 89d25faf Seth Mos
						}
426
						echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
427
					}
428
429
					?>
430
					</select>
431
432 3e6ec5df Renato Botelho
					<?=gettext("Style:");?>
433 89d25faf Seth Mos
					<select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
434
					<?php
435
					foreach ($styles as $style => $styled) {
436
						echo "<option value=\"$style\"";
437
						if ($style == $curstyle) echo " selected";
438
						echo ">" . htmlspecialchars($styled) . "</option>\n";
439
					}
440
					?>
441 7d906758 smos
					</select>
442
					
443 e4b57d26 Renato Botelho
					<?php
444 47e68f48 smos
					if($curcat <> "custom") {
445
					?>
446 3e6ec5df Renato Botelho
						<?=gettext("Period:");?>
447 47e68f48 smos
						<select name="period" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
448
						<?php
449
						foreach ($periods as $period => $value) {
450
							echo "<option value=\"$period\"";
451 1d80829e Carlos Eduardo Ramos
							if ($period == $curperiod) echo " selected";
452 47e68f48 smos
							echo ">" . htmlspecialchars($value) . "</option>\n";
453
						}
454 7d906758 smos
					}
455
					?>
456 89d25faf Seth Mos
					</select>
457
					<?php
458
459 47e68f48 smos
					if($curcat == "custom") {
460 6b0c5ae6 smos
						?>
461
						<?=gettext("Start:");?>
462
						<input type="text" name="start" class="formfldunknown" length="32" value="<?php echo $start;?>">
463
						<?=gettext("End:");?>
464
						<input type="text" name="end" class="formfldunknown" length="32" value="<?php echo $now;?>">
465 b8219006 Carlos Eduardo Ramos
						<input type="submit" name="Submit" value="<?=gettext("Go"); ?>">
466 3e6ec5df Renato Botelho
						<?php
467 6b0c5ae6 smos
						$curdatabase = $curoption;
468
						$graph = "custom-$curdatabase";
469 9cd5e6f5 Erik Fonnesbeck
						if(in_array($curdatabase, $custom_databases)) {
470 6b0c5ae6 smos
							echo "<tr><td colspan=2 class=\"list\">\n";
471
							echo "<IMG BORDER='0' name='{$graph}-{$curoption}-{$curdatabase}' ";
472
							echo "id='{$graph}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
473
							echo "SRC=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
474
							echo "<br /><hr><br />\n";								
475
							echo "</td></tr>\n";
476
						}
477
					} else {
478
						foreach($graphs as $graph) {
479
							/* check which databases are valid for our category */
480
							foreach($ui_databases as $curdatabase) {
481
								if(! preg_match("/($curcat)/i", $curdatabase)) {
482
									continue;
483
								}
484
								$optionc = split("-", $curdatabase);
485
								$search = array("-", ".rrd", $optionc);
486
								$replace = array(" :: ", "", $friendly);
487
								switch($curoption) {
488
									case "outbound":
489 2103b252 Erik Fonnesbeck
										/* make sure we do not show the placeholder databases in the outbound view */
490
										if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
491
											continue 2;
492
										}
493 6b0c5ae6 smos
										/* only show interfaces with a gateway */
494
										$optionc = "$optionc[0]";
495
										if(!interface_has_gateway($optionc)) {
496 2103b252 Erik Fonnesbeck
											if(!isset($gateways_arr)) {
497
												if(preg_match("/quality/i", $curdatabase))
498
													$gateways_arr = return_gateways_array();
499
												else
500
													$gateways_arr = array();
501
											}
502 44aef543 Erik Fonnesbeck
											$found_gateway = false;
503
											foreach ($gateways_arr as $gw) {
504
												if ($gw['name'] == $optionc) {
505
													$found_gateway = true;
506
													break;
507
												}
508
											}
509
											if(!$found_gateway) {
510 6b0c5ae6 smos
												continue 2;
511
											}
512
										}
513 44aef543 Erik Fonnesbeck
										if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
514 a927edff Seth Mos
											continue 2;
515
										}
516 6b0c5ae6 smos
										break;
517
									case "allgraphs":
518
										/* make sure we do not show the placeholder databases in the all view */
519
										if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
520
											continue 2;
521
										}
522
										break;
523
									default:
524
										/* just use the name here */
525 44aef543 Erik Fonnesbeck
										if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
526 6b0c5ae6 smos
											continue 2;
527
										}
528
								}
529 9cd5e6f5 Erik Fonnesbeck
								if(in_array($curdatabase, $ui_databases)) {
530 6b0c5ae6 smos
									$dates = get_dates($curperiod, $graph);
531
									$start = $dates['start'];
532
									$end = $dates['end'];
533
									echo "<tr><td colspan=2 class=\"list\">\n";
534
									echo "<IMG BORDER='0' name='{$graph}-{$curoption}-{$curdatabase}' ";
535
									echo "id='{$graph}-{$curoption}-{$curdatabase}' ALT=\"$prettydb Graph\" ";
536
									echo "SRC=\"status_rrd_graph_img.php?start={$start}&amp;end={$end}&amp;database={$curdatabase}&amp;style={$curstyle}&amp;graph={$graph}\" />\n";
537
									echo "<br /><hr><br />\n";								
538
									echo "</td></tr>\n";
539
								}
540 89d25faf Seth Mos
							}
541
						}
542
					}
543
					?>
544
					</td>
545
				</tr>
546
				<tr>
547
					<td colspan=2 class="list">
548
					<script language="javascript">
549
						function update_graph_images() {
550
							//alert('updating');
551
							var randomid = Math.floor(Math.random()*11);
552
							<?php
553 7d906758 smos
							foreach($graphs as $graph) {
554 683bf031 Seth Mos
								/* check which databases are valid for our category */
555 9cd5e6f5 Erik Fonnesbeck
								foreach($ui_databases as $curdatabase) {
556 683bf031 Seth Mos
									if(! stristr($curdatabase, $curcat)) {
557
										continue;
558
									}
559
									$optionc = split("-", $curdatabase);
560
									$search = array("-", ".rrd", $optionc);
561
									$replace = array(" :: ", "", $friendly);
562
									switch($curoption) {
563
										case "outbound":
564 2103b252 Erik Fonnesbeck
											/* make sure we do not show the placeholder databases in the outbound view */
565
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
566
												continue 2;
567
											}
568
											/* only show interfaces with a gateway */
569 44aef543 Erik Fonnesbeck
											$optionc = "$optionc[0]";
570 2e76e612 Seth Mos
											if(!interface_has_gateway($optionc)) {
571 44aef543 Erik Fonnesbeck
												if(!isset($gateways_arr))
572 2103b252 Erik Fonnesbeck
													if(preg_match("/quality/i", $curdatabase))
573
														$gateways_arr = return_gateways_array();
574
													else
575
														$gateways_arr = array();
576 44aef543 Erik Fonnesbeck
												$found_gateway = false;
577
												foreach ($gateways_arr as $gw) {
578
													if ($gw['name'] == $optionc) {
579
														$found_gateway = true;
580
														break;
581
													}
582
												}
583
												if(!$found_gateway) {
584 683bf031 Seth Mos
													continue 2;
585 44aef543 Erik Fonnesbeck
												}
586
											}
587
											if(! preg_match("/(^$optionc-|-$optionc\\.)/i", $curdatabase)) {
588
												continue 2;
589 683bf031 Seth Mos
											}
590 9850b625 Seth Mos
											break;
591 683bf031 Seth Mos
										case "allgraphs":
592 9850b625 Seth Mos
											/* make sure we do not show the placeholder databases in the all view */
593
											if((stristr($curdatabase, "outbound")) || (stristr($curdatabase, "allgraphs"))) {
594
												continue 2;
595
											}
596
											break;
597 683bf031 Seth Mos
										default:
598
											/* just use the name here */
599 44aef543 Erik Fonnesbeck
											if(! preg_match("/(^$curoption-|-$curoption\\.)/i", $curdatabase)) {
600 683bf031 Seth Mos
												continue 2;
601
											}
602
									}
603 7d906758 smos
									$dates = get_dates($curperiod, $graph);
604
									$start = $dates['start'];
605 d60f510a smos
									if($curperiod == "current") {
606
										$end = $dates['end'];
607
									}
608 683bf031 Seth Mos
									/* generate update events utilizing prototype $('') feature */
609
									echo "\n";
610 0da02ef5 Evgeny Yurchenko
									echo "\t\t\$('{$graph}-{$curoption}-{$curdatabase}').src='status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid;\n";
611 683bf031 Seth Mos
									}
612
								}
613 89d25faf Seth Mos
							?>
614
							window.setTimeout('update_graph_images()', 355000);
615
						}
616
						window.setTimeout('update_graph_images()', 355000);
617
					</script>
618
					</form>
619
					</td>
620
				</tr>
621
			</table>
622
		</div>
623
		</td>
624
	</tr>
625
</table>
626 37285f69 Scott Ullrich
627
<?php include("fend.inc"); ?>
628
</body>
629
</html>