Project

General

Profile

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