Project

General

Profile

Download (10.3 KB) Statistics
| Branch: | Tag: | Revision:
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 94556105 Scott Ullrich
// Get configured interface list
58 61ab4cd3 Scott Ullrich
$ifdescrs = get_configured_interface_with_descr();
59 9f5d14ce jim-p
if (isset($config['ipsec']['enable']))
60
	$ifdescrs['enc0'] = "IPsec";
61
foreach (array('server', 'client') as $mode) {
62
	if (is_array($config['openvpn']["openvpn-{$mode}"])) {
63
		foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) {
64
			if (!isset($setting['disable'])) {
65
				$ifdescrs['ovpn' . substr($mode, 0, 1) . $setting['vpnid']] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']);
66
			}
67
		}
68
	}
69
}
70 43a0ac8a Scott Ullrich
71 50b2f6ab Scott Ullrich
if ($_GET['if']) {
72 5b237745 Scott Ullrich
	$curif = $_GET['if'];
73 50b2f6ab Scott Ullrich
	$found = false;
74
	foreach($ifdescrs as $descr => $ifdescr) 
75
		if($descr == $curif) $found = true;
76
	if(!$found) {
77
		Header("Location: status_graph.php");
78
		exit;
79
	}
80
} else {
81 029c5888 Scott Ullrich
	$curif = "wan";
82 50b2f6ab Scott Ullrich
}
83 769cdf3b Bill Marquette
84 d0033721 Carlos Eduardo Ramos
$pgtitle = array(gettext("Status"),gettext("Traffic Graph"));
85 f0a3b883 Scott Ullrich
86 4df96eff Scott Ullrich
include("head.inc");
87
88 5b237745 Scott Ullrich
?>
89
90
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
91 f0a3b883 Scott Ullrich
92
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
93
<script src="/javascript/scriptaculous/scriptaculous.js" type="text/javascript"></script>
94
<script language="javascript" type="text/javascript">
95
96
function updateBandwidth(){
97 50b2f6ab Scott Ullrich
    var hostinterface = "<?php echo htmlspecialchars($curif); ?>";
98 f0a3b883 Scott Ullrich
    bandwidthAjax(hostinterface);
99
}
100
101
function bandwidthAjax(hostinterface) {
102
	uri = "bandwidth_by_ip.php?if=" + hostinterface;
103
	var opt = {
104
	    // Use GET
105
	    method: 'get',
106
	    asynchronous: true,
107
	    // Handle 404
108
	    on404: function(t) {
109
	        alert('Error 404: location "' + t.statusText + '" was not found.');
110
	    },
111
	    // Handle other errors
112
	    onFailure: function(t) {
113
	        alert('Error ' + t.status + ' -- ' + t.statusText);
114
	    },
115
		onSuccess: function(t) {
116
			updateBandwidthHosts(t.responseText);
117
	    }
118
	}
119
	new Ajax.Request(uri, opt);
120
}
121
122
function updateBandwidthHosts(data){
123
    var hosts_split = data.split("|");
124
    d = document;
125
    //parse top ten bandwidth abuser hosts
126
    for (var y=0; y<10; y++){
127
        if (hosts_split[y] != "" && hosts_split[y] != "no info"){
128
            if (hosts_split[y]) {
129
                hostinfo = hosts_split[y].split(";");
130
131
                //update host ip info
132
                var HostIpID = "hostip" + y;
133
                var hostip = d.getElementById(HostIpID);
134
                hostip.innerHTML = hostinfo[0];
135
136
                //update bandwidth inbound to host
137
                var hostbandwidthInID = "bandwidthin" + y;
138
                var hostbandwidthin = d.getElementById(hostbandwidthInID);
139 e774e3b3 Ermal
                hostbandwidthin.innerHTML = hostinfo[1] + " Bits/sec";
140 f0a3b883 Scott Ullrich
141
                //update bandwidth outbound from host
142
                var hostbandwidthOutID = "bandwidthout" + y;
143
                var hostbandwidthOut = d.getElementById(hostbandwidthOutID);
144 e774e3b3 Ermal
                hostbandwidthOut.innerHTML = hostinfo[2] + " Bits/sec";
145 f0a3b883 Scott Ullrich
146
                //make the row appear if hidden
147
                var rowid = "host" + y;
148
                textlink = d.getElementById(rowid);
149
                if (textlink.style.display == "none"){
150
                     //hide rows that contain no data
151
                     Effect.Appear(rowid, {duration:1});
152
                }
153
            }
154
        }
155
        else
156
        {
157
            var rowid = "host" + y;
158
            textlink = d.getElementById(rowid);
159
            if (textlink.style.display != "none"){
160
                //hide rows that contain no data
161
                Effect.Fade(rowid, {duration:2});
162
            }
163
        }
164
    }
165
    
166 e6dd418d sullrich
    setTimeout('updateBandwidth()', 1000);
167 f0a3b883 Scott Ullrich
}
168
169
170
</script>
171
172 5b237745 Scott Ullrich
<?php include("fbegin.inc"); ?>
173
<?php
174 9573d170 Scott Ullrich
175 872ce0dd Ermal Luçi
/* link the ipsec interface magically */
176 c6dfd289 jim-p
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) 
177 872ce0dd Ermal Luçi
	$ifdescrs['enc0'] = "IPsec";
178 c1abd446 Seth Mos
179 5b237745 Scott Ullrich
?>
180 60f9e276 Bill Marquette
<form name="form1" action="status_graph.php" method="get" style="padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid #999999">
181 59bb015e Carlos Eduardo Ramos
<?=gettext("Interface"); ?>:
182 b5c78501 Seth Mos
<select name="if" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
183 5b237745 Scott Ullrich
<?php
184
foreach ($ifdescrs as $ifn => $ifd) {
185
	echo "<option value=\"$ifn\"";
186
	if ($ifn == $curif) echo " selected";
187 82bf9411 Scott Ullrich
	echo ">" . htmlspecialchars($ifd) . "</option>\n";
188 5b237745 Scott Ullrich
}
189
?>
190
</select>
191
</form>
192 570cdbcf Bill Marquette
<p><form method="post" action="status_graph.php">
193 8ab3e9ed Erik Kristensen
</form>
194 da07227e Scott Ullrich
<p>
195 e57c91a2 Renato Botelho
<div id="niftyOutter">
196
    <div id="col1" style="float: left; width: 46%; padding: 5px; position: relative;">
197 cb3b4ebc Scott Ullrich
        <object data="graph.php?ifnum=<?=htmlspecialchars($curif);?>&ifname=<?=rawurlencode($ifdescrs[htmlspecialchars($curif)]);?>" type="image/svg+xml" width="<?=$width;?>" height="<?=$height;?>">
198
            <param name="src" value="graph.php?ifnum=<?=htmlspecialchars($curif);?>&ifname=<?=rawurlencode($ifdescrs[htmlspecialchars($curif)]);?>" />
199 d0033721 Carlos Eduardo Ramos
            <?=gettext("Your browser does not support the type SVG! You need to either use Firefox or download the Adobe SVG plugin"); ?>.
200 f0a3b883 Scott Ullrich
        </object>
201
    </div>
202 e57c91a2 Renato Botelho
    <div id="col2" style="float: right; width: 48%; padding: 5px; position: relative;">
203 f0a3b883 Scott Ullrich
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
204
            <tr>
205 d0033721 Carlos Eduardo Ramos
                <td class="listtopic" valign="top"><?=gettext("Host IP"); ?></td>
206
                <td class="listtopic" valign="top"><?=gettext("Bandwidth In"); ?></td>
207
                <td class="listtopic" valign="top"><?=gettext("Bandwidth Out"); ?></td>
208 f0a3b883 Scott Ullrich
           </tr>
209
           <tr id="host0" style="display:none">
210
                <td id="hostip0" class="vncell">
211
                </td>
212
                <td id="bandwidthin0" class="listr">
213
                </td>
214
                <td id="bandwidthout0" class="listr">
215
                </td>
216
           </tr>
217
           <tr id="host1" style="display:none">
218
                <td id="hostip1" class="vncell">
219
                </td>
220
                <td id="bandwidthin1" class="listr">
221
                </td>
222
                <td id="bandwidthout1" class="listr">
223
                </td>
224
           </tr>
225
           <tr id="host2" style="display:none">
226
                <td id="hostip2" class="vncell">
227
                </td>
228
                <td id="bandwidthin2" class="listr">
229
                </td>
230
                <td id="bandwidthout2" class="listr">
231
                </td>
232
           </tr>
233
           <tr id="host3" style="display:none">
234
                <td id="hostip3" class="vncell">
235
                </td>
236
                <td id="bandwidthin3" class="listr">
237
                </td>
238
                <td id="bandwidthout3" class="listr">
239
                </td>
240
           </tr>
241
           <tr id="host4" style="display:none">
242
                <td id="hostip4" class="vncell">
243
                </td>
244
                <td id="bandwidthin4" class="listr">
245
                </td>
246
                <td id="bandwidthout4" class="listr">
247
                </td>
248
           </tr>
249
           <tr id="host5" style="display:none">
250
                <td id="hostip5" class="vncell">
251
                </td>
252
                <td id="bandwidthin5" class="listr">
253
                </td>
254
                <td id="bandwidthout5" class="listr">
255
                </td>
256
           </tr>
257
           <tr id="host6" style="display:none">
258
                <td id="hostip6" class="vncell">
259
                </td>
260
                <td id="bandwidthin6" class="listr">
261
                </td>
262
                <td id="bandwidthout6" class="listr">
263
                </td>
264
           </tr>
265
           <tr id="host7" style="display:none">
266
                <td id="hostip7" class="vncell">
267
                </td>
268
                <td id="bandwidthin7" class="listr">
269
                </td>
270
                <td id="bandwidthout7" class="listr">
271
                </td>
272
           </tr>
273
           <tr id="host8" style="display:none">
274
                <td id="hostip8" class="vncell">
275
                </td>
276
                <td id="bandwidthin8" class="listr">
277
                </td>
278
                <td id="bandwidthout8" class="listr">
279
                </td>
280
           </tr>
281
           <tr id="host9" style="display:none">
282
                <td id="hostip9" class="vncell">
283
                </td>
284
                <td id="bandwidthin9" class="listr">
285
                </td>
286
                <td id="bandwidthout9" class="listr">
287
                </td>
288
           </tr>
289
        </table>
290 e57c91a2 Renato Botelho
	</div>
291
	<div style="clear: both;"></div>
292 8ab3e9ed Erik Kristensen
</div>
293 e5fee340 Scott Ullrich
<p><span class="red"><strong><?=gettext("Note"); ?>:</strong></span> <?=gettext("the"); ?> <a href="http://www.adobe.com/svg/viewer/install/" target="_blank"><?=gettext("Adobe SVG Viewer"); ?></a>, <?=gettext("Firefox 1.5 or later or other browser supporting SVG is required to view the graph"); ?>.
294 8ab3e9ed Erik Kristensen
295 5b237745 Scott Ullrich
<?php include("fend.inc"); ?>
296 f0a3b883 Scott Ullrich
297
<script type="text/javascript">
298
window.onload = function(in_event)
299
	{
300
        updateBandwidth();
301
    }
302
303
</script>
304 5b237745 Scott Ullrich
</body>
305
</html>