Project

General

Profile

Download (4.86 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	status_rrd_graph.php
5
	Part of pfSense
6
	Copyright (C) 2006 Seth Mos <seth.mos@xs4all.nl>
7
	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

    
31
require("guiconfig.inc");
32

    
33
if ($_GET['database']) {
34
	$curdatabase = $_GET['database'];
35
} else {
36
	$curdatabase = "wan-traffic.rrd";
37
}
38

    
39
if ($_GET['style']) {
40
	$curstyle = $_GET['style'];
41
} else {
42
	$curstyle = "inverse";
43
}
44

    
45
$pgtitle = gettext("Status: RRD Graphs");
46
include("head.inc");
47

    
48
$rrddbpath = "/var/db/rrd/";
49

    
50
/* XXX: (billm) do we have an exec() type function that does this type of thing? */
51
exec("cd $rrddbpath;/usr/bin/find -name *.rrd", $databases);
52
rsort($databases);
53

    
54
/* Deduce a interface if possible and use the description */
55
$curif = split("-", $curdatabase);
56
$curif = "$curif[0]";
57
$friendly = convert_friendly_interface_to_friendly_descr(strtolower($curif));
58
$search = array("-", ".rrd", $curif);
59
$replace = array(" :: ", "", $friendly);
60
$prettydb = ucwords(str_replace($search, $replace, $curdatabase));
61

    
62
$styles = array('inverse' => 'Inverse', 'absolute' => 'Absolute');
63

    
64
?>
65
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
66
<script src="/javascript/scriptaculous/scriptaculous.js" type="text/javascript"></script>
67

    
68
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
69
<?php include("fbegin.inc"); ?>
70
<p class="pgtitle"><?=$pgtitle?></p>
71
<p><b><?=gettext("Note: Change of color and/or style may not take effect until the next 
72
refresh");?></b></p>
73
<form name="form1" action="status_rrd_graph.php" method="get" style="padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid #999999">
74
<?=gettext("Graphs:");?>
75
<select name="database" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
76
<?php
77
foreach ($databases as $db => $database) {
78
	echo "<option value=\"$database\"";
79
	if ($database == $curdatabase) echo " selected";
80
	/* Deduce a interface if possible and use the description */
81
	$curif = split("-", $database);
82
	$curif = "$curif[0]";
83
	$friendly = convert_friendly_interface_to_friendly_descr(strtolower($curif));
84
	$search = array("-", ".rrd", $curif);
85
	$replace = array(" :: ", "", $friendly);
86
	$prettyprint = ucwords(str_replace($search, $replace, $database));
87
	echo ">" . htmlspecialchars($prettyprint) . "</option>\n";
88
}
89
?>
90
</select>
91
<?=gettext("Style:");?>
92
<select name="style" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
93
<?php
94
foreach ($styles as $style => $styled) {
95
	echo "<option value=\"$style\"";
96
	if ($style == $curstyle) echo " selected";
97
	echo ">" . htmlspecialchars($styled) . "</option>\n";
98
}
99
?>
100
</select>
101
</form>
102

    
103
<div style="text-align: center;">
104
<?php
105

    
106
$periods = array("4h", "16h", "48h", "32d", "6m", "16m");
107

    
108
if((file_exists("{$rrddbpath}{$curdatabase}"))) {
109
	foreach($periods as $period => $interval) {
110
		PRINT "<B>Analysis for $prettydb -- $interval</B><br />";
111
		PRINT "\n<IMG BORDER='1' name='{$interval}-{$curif}' id='{$interval}-{$curif}' ALT=\"$prettydb Graph\" SRC=\"status_rrd_graph_img.php?interval=$interval&amp;database={$curdatabase}&amp;style={$curstyle}\" /><br /><br />";
112
	}
113
} else {
114
	PRINT "<b>There is no database available to generate $prettydb from.</b><br />";
115
}
116

    
117
?>
118

    
119
</div>
120

    
121
<script language="javascript">
122
	function update_graph_images() {
123
		//alert('updating');
124
		var randomid = Math.floor(Math.random()*11);
125
		<?php
126
			/* generate update events utilizing prototype $('') feature */
127
			echo "\n";
128
			foreach($periods as $period => $interval)
129
				echo "\t\t\$('{$interval}-{$curif}').src='status_rrd_graph_img.php?interval={$interval}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid;\n";
130
		?>
131
		window.setTimeout('update_graph_images()', 355000);
132
	}
133
	window.setTimeout('update_graph_images()', 355000);
134
</script>
135

    
136
<?php include("fend.inc"); ?>
137
</body>
138
</html>
(124-124/167)