Project

General

Profile

Download (4.11 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
?>
57

    
58
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
59
<script src="/javascript/scriptaculous/scriptaculous.js" type="text/javascript"></script>
60

    
61
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
62
<?php include("fbegin.inc"); ?>
63
<p class="pgtitle"><?=$pgtitle?></p>
64
<?php
65
$ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
66
$graphs = array('traffic' => 'Traffic', 'quality' => 'Quality', 'queues' => 'Queues', 'packets' => 'Packets', 'spamd' => 'Spamd');
67

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

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

    
101
foreach($periods as $period => $interval) {
102

    
103
	PRINT "<B>Analysis for $curif -- $interval $curgraph</B><BR>";
104
	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\"><BR><BR>";
105
}
106

    
107
?>
108

    
109
</div>
110

    
111
<script language="javascript">
112
	function update_graph_images() {
113
		//alert('updating');
114
		var randomid = Math.floor(Math.random()*11);
115
		<?php
116
			/* generate update events utilizing prototype $('') feature */
117
			echo "\n";
118
			foreach($periods as $period => $interval) 
119
				echo "\t\t\$('{$curif}-{$interval}-{$curgraph}').src='status_rrd_graph_img.php?if={$curif}&interval={$interval}&graph={$curgraph}&tmp=' + randomid;\n";	
120
		?>	
121
		window.setTimeout('update_graph_images()', 355000);
122
	}
123
	window.setTimeout('update_graph_images()', 355000);
124
</script>
125

    
126
<?php include("fend.inc"); ?>
127
</body>
128
</html>
(122-122/163)