Project

General

Profile

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