Project

General

Profile

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