Project

General

Profile

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