Project

General

Profile

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