1 |
9573d170
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
status_graph.php
|
5 |
6ad24605
|
Scott Ullrich
|
Part of pfSense
|
6 |
|
|
Copyright (C) 2004 Scott Ullrich
|
7 |
|
|
All rights reserved.
|
8 |
9573d170
|
Scott Ullrich
|
|
9 |
6ad24605
|
Scott Ullrich
|
Originally part of m0n0wall (http://m0n0.ch/wall)
|
10 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11 |
|
|
All rights reserved.
|
12 |
9573d170
|
Scott Ullrich
|
|
13 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
14 |
|
|
modification, are permitted provided that the following conditions are met:
|
15 |
9573d170
|
Scott Ullrich
|
|
16 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
17 |
|
|
this list of conditions and the following disclaimer.
|
18 |
9573d170
|
Scott Ullrich
|
|
19 |
5b237745
|
Scott Ullrich
|
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 |
9573d170
|
Scott Ullrich
|
|
23 |
5b237745
|
Scott Ullrich
|
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 |
1d333258
|
Scott Ullrich
|
/*
|
35 |
|
|
pfSense_MODULE: routing
|
36 |
|
|
*/
|
37 |
5b237745
|
Scott Ullrich
|
|
38 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
39 |
|
|
##|*IDENT=page-status-trafficgraph
|
40 |
|
|
##|*NAME=Status: Traffic Graph page
|
41 |
|
|
##|*DESCR=Allow access to the 'Status: Traffic Graph' page.
|
42 |
|
|
##|*MATCH=status_graph.php*
|
43 |
|
|
##|-PRIV
|
44 |
|
|
|
45 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
46 |
|
|
|
47 |
9573d170
|
Scott Ullrich
|
if ($_POST['width'])
|
48 |
|
|
$width = $_POST['width'];
|
49 |
|
|
else
|
50 |
f0a3b883
|
Scott Ullrich
|
$width = "100%";
|
51 |
9573d170
|
Scott Ullrich
|
|
52 |
dd521ae8
|
Scott Ullrich
|
if ($_POST['height'])
|
53 |
9573d170
|
Scott Ullrich
|
$height = $_POST['height'];
|
54 |
|
|
else
|
55 |
f0a3b883
|
Scott Ullrich
|
$height = "200";
|
56 |
9573d170
|
Scott Ullrich
|
|
57 |
c1abd446
|
Seth Mos
|
|
58 |
872ce0dd
|
Ermal Luçi
|
if ($_GET['if'])
|
59 |
5b237745
|
Scott Ullrich
|
$curif = $_GET['if'];
|
60 |
872ce0dd
|
Ermal Luçi
|
else
|
61 |
029c5888
|
Scott Ullrich
|
$curif = "wan";
|
62 |
769cdf3b
|
Bill Marquette
|
|
63 |
d88c6a9f
|
Scott Ullrich
|
$pgtitle = array("Status","Traffic Graph");
|
64 |
f0a3b883
|
Scott Ullrich
|
|
65 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
66 |
|
|
|
67 |
5b237745
|
Scott Ullrich
|
?>
|
68 |
|
|
|
69 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
70 |
f0a3b883
|
Scott Ullrich
|
|
71 |
|
|
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
|
72 |
|
|
<script src="/javascript/scriptaculous/scriptaculous.js" type="text/javascript"></script>
|
73 |
|
|
<script language="javascript" type="text/javascript">
|
74 |
|
|
|
75 |
|
|
function updateBandwidth(){
|
76 |
|
|
var hostinterface = "<?php echo $curif; ?>";
|
77 |
|
|
bandwidthAjax(hostinterface);
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
function bandwidthAjax(hostinterface) {
|
81 |
|
|
uri = "bandwidth_by_ip.php?if=" + hostinterface;
|
82 |
|
|
var opt = {
|
83 |
|
|
// Use GET
|
84 |
|
|
method: 'get',
|
85 |
|
|
asynchronous: true,
|
86 |
|
|
// Handle 404
|
87 |
|
|
on404: function(t) {
|
88 |
|
|
alert('Error 404: location "' + t.statusText + '" was not found.');
|
89 |
|
|
},
|
90 |
|
|
// Handle other errors
|
91 |
|
|
onFailure: function(t) {
|
92 |
|
|
alert('Error ' + t.status + ' -- ' + t.statusText);
|
93 |
|
|
},
|
94 |
|
|
onSuccess: function(t) {
|
95 |
|
|
updateBandwidthHosts(t.responseText);
|
96 |
|
|
}
|
97 |
|
|
}
|
98 |
|
|
new Ajax.Request(uri, opt);
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
function updateBandwidthHosts(data){
|
102 |
|
|
var hosts_split = data.split("|");
|
103 |
|
|
d = document;
|
104 |
|
|
//parse top ten bandwidth abuser hosts
|
105 |
|
|
for (var y=0; y<10; y++){
|
106 |
|
|
if (hosts_split[y] != "" && hosts_split[y] != "no info"){
|
107 |
|
|
if (hosts_split[y]) {
|
108 |
|
|
hostinfo = hosts_split[y].split(";");
|
109 |
|
|
|
110 |
|
|
//update host ip info
|
111 |
|
|
var HostIpID = "hostip" + y;
|
112 |
|
|
var hostip = d.getElementById(HostIpID);
|
113 |
|
|
hostip.innerHTML = hostinfo[0];
|
114 |
|
|
|
115 |
|
|
//update bandwidth inbound to host
|
116 |
|
|
var hostbandwidthInID = "bandwidthin" + y;
|
117 |
|
|
var hostbandwidthin = d.getElementById(hostbandwidthInID);
|
118 |
|
|
hostbandwidthin.innerHTML = hostinfo[1] + " Bytes/sec";
|
119 |
|
|
|
120 |
|
|
//update bandwidth outbound from host
|
121 |
|
|
var hostbandwidthOutID = "bandwidthout" + y;
|
122 |
|
|
var hostbandwidthOut = d.getElementById(hostbandwidthOutID);
|
123 |
|
|
hostbandwidthOut.innerHTML = hostinfo[2] + " Bytes/sec";
|
124 |
|
|
|
125 |
|
|
//make the row appear if hidden
|
126 |
|
|
var rowid = "host" + y;
|
127 |
|
|
textlink = d.getElementById(rowid);
|
128 |
|
|
if (textlink.style.display == "none"){
|
129 |
|
|
//hide rows that contain no data
|
130 |
|
|
Effect.Appear(rowid, {duration:1});
|
131 |
|
|
}
|
132 |
|
|
}
|
133 |
|
|
}
|
134 |
|
|
else
|
135 |
|
|
{
|
136 |
|
|
var rowid = "host" + y;
|
137 |
|
|
textlink = d.getElementById(rowid);
|
138 |
|
|
if (textlink.style.display != "none"){
|
139 |
|
|
//hide rows that contain no data
|
140 |
|
|
Effect.Fade(rowid, {duration:2});
|
141 |
|
|
}
|
142 |
|
|
}
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
setTimeout('updateBandwidth()', 3000);
|
146 |
|
|
}
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
</script>
|
150 |
|
|
|
151 |
5b237745
|
Scott Ullrich
|
<?php include("fbegin.inc"); ?>
|
152 |
|
|
<?php
|
153 |
f0a3b883
|
Scott Ullrich
|
$ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
|
154 |
|
|
|
155 |
|
|
for($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
|
156 |
|
|
if(isset($config['interfaces']['opt' . $j]['enable']))
|
157 |
|
|
$ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
|
158 |
|
|
}
|
159 |
9573d170
|
Scott Ullrich
|
|
160 |
872ce0dd
|
Ermal Luçi
|
/* link the ipsec interface magically */
|
161 |
|
|
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['mobileclients']['enable']))
|
162 |
|
|
$ifdescrs['enc0'] = "IPsec";
|
163 |
c1abd446
|
Seth Mos
|
|
164 |
5b237745
|
Scott Ullrich
|
?>
|
165 |
60f9e276
|
Bill Marquette
|
<form name="form1" action="status_graph.php" method="get" style="padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid #999999">
|
166 |
9573d170
|
Scott Ullrich
|
Interface:
|
167 |
b5c78501
|
Seth Mos
|
<select name="if" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
|
168 |
5b237745
|
Scott Ullrich
|
<?php
|
169 |
|
|
foreach ($ifdescrs as $ifn => $ifd) {
|
170 |
|
|
echo "<option value=\"$ifn\"";
|
171 |
|
|
if ($ifn == $curif) echo " selected";
|
172 |
|
|
echo ">" . htmlspecialchars($ifd) . "</option>\n";
|
173 |
|
|
}
|
174 |
|
|
?>
|
175 |
|
|
</select>
|
176 |
|
|
</form>
|
177 |
f873da66
|
Chris Buechler
|
<p><span class="red"><strong>Note:</strong></span> the <a href="http://www.adobe.com/svg/viewer/install/" target="_blank">Adobe SVG Viewer</a>, Firefox 1.5 or later or other browser supporting SVG is required to view the graph.
|
178 |
570cdbcf
|
Bill Marquette
|
<p><form method="post" action="status_graph.php">
|
179 |
8ab3e9ed
|
Erik Kristensen
|
</form>
|
180 |
da07227e
|
Scott Ullrich
|
<p>
|
181 |
f0a3b883
|
Scott Ullrich
|
<div>
|
182 |
|
|
<div class="widgetdiv" style="padding: 5px; float:left; width:46%">
|
183 |
|
|
<object data="graph.php?ifnum=<?=$curif;?>&ifname=<?=rawurlencode($ifdescrs[$curif]);?>" type="image/svg+xml" width="<?=$width;?>" height="<?=$height;?>">
|
184 |
|
|
<param name="src" value="graph.php?ifnum=<?=$curif;?>&ifname=<?=rawurlencode($ifdescrs[$curif]);?>" />
|
185 |
|
|
Your browser does not support the type SVG! You need to either use Firefox or download the Adobe SVG plugin.
|
186 |
|
|
</object>
|
187 |
|
|
</div>
|
188 |
|
|
<div class="widgetdiv" style="padding: 5px; float:right; width:48%">
|
189 |
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
190 |
|
|
<tr>
|
191 |
|
|
<td class="listtopic" valign="top">Host IP</td>
|
192 |
|
|
<td class="listtopic" valign="top">Bandwidth In</td>
|
193 |
|
|
<td class="listtopic" valign="top">Bandwidth Out</td>
|
194 |
|
|
</tr>
|
195 |
|
|
<tr id="host0" style="display:none">
|
196 |
|
|
<td id="hostip0" class="vncell">
|
197 |
|
|
</td>
|
198 |
|
|
<td id="bandwidthin0" class="listr">
|
199 |
|
|
</td>
|
200 |
|
|
<td id="bandwidthout0" class="listr">
|
201 |
|
|
</td>
|
202 |
|
|
</tr>
|
203 |
|
|
<tr id="host1" style="display:none">
|
204 |
|
|
<td id="hostip1" class="vncell">
|
205 |
|
|
</td>
|
206 |
|
|
<td id="bandwidthin1" class="listr">
|
207 |
|
|
</td>
|
208 |
|
|
<td id="bandwidthout1" class="listr">
|
209 |
|
|
</td>
|
210 |
|
|
</tr>
|
211 |
|
|
<tr id="host2" style="display:none">
|
212 |
|
|
<td id="hostip2" class="vncell">
|
213 |
|
|
</td>
|
214 |
|
|
<td id="bandwidthin2" class="listr">
|
215 |
|
|
</td>
|
216 |
|
|
<td id="bandwidthout2" class="listr">
|
217 |
|
|
</td>
|
218 |
|
|
</tr>
|
219 |
|
|
<tr id="host3" style="display:none">
|
220 |
|
|
<td id="hostip3" class="vncell">
|
221 |
|
|
</td>
|
222 |
|
|
<td id="bandwidthin3" class="listr">
|
223 |
|
|
</td>
|
224 |
|
|
<td id="bandwidthout3" class="listr">
|
225 |
|
|
</td>
|
226 |
|
|
</tr>
|
227 |
|
|
<tr id="host4" style="display:none">
|
228 |
|
|
<td id="hostip4" class="vncell">
|
229 |
|
|
</td>
|
230 |
|
|
<td id="bandwidthin4" class="listr">
|
231 |
|
|
</td>
|
232 |
|
|
<td id="bandwidthout4" class="listr">
|
233 |
|
|
</td>
|
234 |
|
|
</tr>
|
235 |
|
|
<tr id="host5" style="display:none">
|
236 |
|
|
<td id="hostip5" class="vncell">
|
237 |
|
|
</td>
|
238 |
|
|
<td id="bandwidthin5" class="listr">
|
239 |
|
|
</td>
|
240 |
|
|
<td id="bandwidthout5" class="listr">
|
241 |
|
|
</td>
|
242 |
|
|
</tr>
|
243 |
|
|
<tr id="host6" style="display:none">
|
244 |
|
|
<td id="hostip6" class="vncell">
|
245 |
|
|
</td>
|
246 |
|
|
<td id="bandwidthin6" class="listr">
|
247 |
|
|
</td>
|
248 |
|
|
<td id="bandwidthout6" class="listr">
|
249 |
|
|
</td>
|
250 |
|
|
</tr>
|
251 |
|
|
<tr id="host7" style="display:none">
|
252 |
|
|
<td id="hostip7" class="vncell">
|
253 |
|
|
</td>
|
254 |
|
|
<td id="bandwidthin7" class="listr">
|
255 |
|
|
</td>
|
256 |
|
|
<td id="bandwidthout7" class="listr">
|
257 |
|
|
</td>
|
258 |
|
|
</tr>
|
259 |
|
|
<tr id="host8" style="display:none">
|
260 |
|
|
<td id="hostip8" class="vncell">
|
261 |
|
|
</td>
|
262 |
|
|
<td id="bandwidthin8" class="listr">
|
263 |
|
|
</td>
|
264 |
|
|
<td id="bandwidthout8" class="listr">
|
265 |
|
|
</td>
|
266 |
|
|
</tr>
|
267 |
|
|
<tr id="host9" style="display:none">
|
268 |
|
|
<td id="hostip9" class="vncell">
|
269 |
|
|
</td>
|
270 |
|
|
<td id="bandwidthin9" class="listr">
|
271 |
|
|
</td>
|
272 |
|
|
<td id="bandwidthout9" class="listr">
|
273 |
|
|
</td>
|
274 |
|
|
</tr>
|
275 |
|
|
</table>
|
276 |
|
|
</div>
|
277 |
8ab3e9ed
|
Erik Kristensen
|
</div>
|
278 |
|
|
|
279 |
5b237745
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|
280 |
f0a3b883
|
Scott Ullrich
|
|
281 |
|
|
<script type="text/javascript">
|
282 |
|
|
window.onload = function(in_event)
|
283 |
|
|
{
|
284 |
|
|
updateBandwidth();
|
285 |
|
|
}
|
286 |
|
|
|
287 |
|
|
</script>
|
288 |
5b237745
|
Scott Ullrich
|
</body>
|
289 |
|
|
</html>
|