Project

General

Profile

Download (4.48 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	status_rrd_graph.php
5
	Part of pfSense
6
	Copyright (C) 2004 Scott Ullrich
7
	All rights reserved.
8

    
9
	Originally part of m0n0wall (http://m0n0.ch/wall)
10
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
11
	All rights reserved.
12

    
13
	Redistribution and use in source and binary forms, with or without
14
	modification, are permitted provided that the following conditions are met:
15

    
16
	1. Redistributions of source code must retain the above copyright notice,
17
	   this list of conditions and the following disclaimer.
18

    
19
	2. Redistributions in binary form must reproduce the above copyright
20
	   notice, this list of conditions and the following disclaimer in the
21
	   documentation and/or other materials provided with the distribution.
22

    
23
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
	POSSIBILITY OF SUCH DAMAGE.
33
*/
34

    
35
require("guiconfig.inc");
36

    
37
function gettext($text) {
38
	return $text;	
39
}
40
if ($_GET['if']) {
41
	$curif = $_GET['if'];
42
	$ifnum = $config['interfaces'][$curif]['if'];
43
} else {
44
	$curif = "wan";
45
}
46

    
47
if ($_GET['graph']) {
48
	$curgraph = $_GET['graph'];
49
} else {
50
	$curgraph = "traffic";
51
}
52

    
53
$pgtitle = gettext("Status: RRD Graphs");
54
include("head.inc");
55

    
56
$rrddbpath = "/var/db/rrd/";
57
$traffic = "-traffic.rrd";
58
$quality = "-quality.rrd";
59
$queues = "-queues.rrd";
60
$queuesdrop = "-queuesdrop.rrd";
61
$packets = "-packets.rrd";
62
$spamd = "spamd.rrd";
63

    
64
?>
65

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

    
69
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
70
<?php include("fbegin.inc"); ?>
71
<p class="pgtitle"><?=$pgtitle?></p>
72
<?php
73
$ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
74
$graphs = array('traffic' => 'Traffic', 'quality' => 'Quality', 'queues' => 'Queues', 'packets' => 'Packets', 'spamd' => 'Spamd');
75

    
76
for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
77
	$ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
78
}
79
?>
80
<form name="form1" action="status_rrd_graph.php" method="get" style="padding-bottom: 10px; margin-bottom: 14px; 
81
border-bottom: 1px solid #999999">
82
<?=gettext("Interface:");?>
83
<select name="if" class="formfld" style="z-index: -10;" onchange="document.form1.submit()">
84
<?php
85
foreach ($ifdescrs as $ifn => $ifd) {
86
	echo "<option value=\"$ifn\"";
87
	if ($ifn == $curif) echo " selected";
88
	echo ">" . htmlspecialchars($ifd) . "</option>\n";
89
}
90
?>
91
</select>
92
<?=gettext("Graph:");?>
93
<select name="graph" class="formfld" style="z-index: -10;" onchange="document.form1.submit()">
94
<?php
95
foreach ($graphs as $graph => $graphd) {
96
	echo "<option value=\"$graph\"";
97
	if ($graph == $curgraph) echo " selected";
98
	echo ">" . htmlspecialchars($graphd) . "</option>\n";
99
}
100
?>
101
</select>
102
</form>
103
<p>
104
<div>
105
<?php
106

    
107
$periods = array("2h", "6h", "48h", "14d", "2m", "18m");
108

    
109
if(file_exists("{$rrddbpath}{$curif}-{$curgraph}.rrd")) {
110
	foreach($periods as $period => $interval) {
111
		PRINT "<B>Analysis for $curif -- $interval $curgraph</B><BR>";
112
	PRINT "\n<IMG BORDER='1' name='{$curif}-{$interval}-{$curgraph}' id='{$curif}-{$interval}-{$curgraph}' ALT=\"$ifname $curgraph Graph\" SRC=\"status_rrd_graph_img.php?if=$curif&interval=$interval&graph=$curgraph&style={$curstyle}&color={$curcolor}\"><BR><BR>";
113
	}
114
} else {
115
	PRINT "<b>There is no database available to generate $curgraph from.</b><br>";
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\$('{$curif}-{$interval}-{$curgraph}').src='status_rrd_graph_img.php?if={$curif}&interval={$interval}&graph={$curgraph}&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>
(122-122/164)