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 |
ce77a9c4
|
Phil Davis
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
7 |
6ad24605
|
Scott Ullrich
|
Copyright (C) 2004 Scott Ullrich
|
8 |
|
|
All rights reserved.
|
9 |
9573d170
|
Scott Ullrich
|
|
10 |
6ad24605
|
Scott Ullrich
|
Originally part of m0n0wall (http://m0n0.ch/wall)
|
11 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
12 |
|
|
All rights reserved.
|
13 |
9573d170
|
Scott Ullrich
|
|
14 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
15 |
|
|
modification, are permitted provided that the following conditions are met:
|
16 |
9573d170
|
Scott Ullrich
|
|
17 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
18 |
|
|
this list of conditions and the following disclaimer.
|
19 |
9573d170
|
Scott Ullrich
|
|
20 |
5b237745
|
Scott Ullrich
|
2. Redistributions in binary form must reproduce the above copyright
|
21 |
|
|
notice, this list of conditions and the following disclaimer in the
|
22 |
|
|
documentation and/or other materials provided with the distribution.
|
23 |
9573d170
|
Scott Ullrich
|
|
24 |
5b237745
|
Scott Ullrich
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
25 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
26 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
27 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
28 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
29 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
30 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
31 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
32 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
33 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
34 |
|
|
*/
|
35 |
e31aa678
|
sbeaver
|
/*
|
36 |
1d333258
|
Scott Ullrich
|
pfSense_MODULE: routing
|
37 |
|
|
*/
|
38 |
5b237745
|
Scott Ullrich
|
|
39 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
40 |
|
|
##|*IDENT=page-status-trafficgraph
|
41 |
|
|
##|*NAME=Status: Traffic Graph page
|
42 |
|
|
##|*DESCR=Allow access to the 'Status: Traffic Graph' page.
|
43 |
|
|
##|*MATCH=status_graph.php*
|
44 |
8e95a671
|
jim-p
|
##|*MATCH=bandwidth_by_ip.php*
|
45 |
8a2f80b2
|
jim-p
|
##|*MATCH=graph.php*
|
46 |
|
|
##|*MATCH=ifstats.php*
|
47 |
6b07c15a
|
Matthew Grooms
|
##|-PRIV
|
48 |
|
|
|
49 |
5b237745
|
Scott Ullrich
|
require("guiconfig.inc");
|
50 |
|
|
|
51 |
42b0c921
|
Phil Davis
|
if ($_POST['width']) {
|
52 |
9573d170
|
Scott Ullrich
|
$width = $_POST['width'];
|
53 |
42b0c921
|
Phil Davis
|
} else {
|
54 |
f0a3b883
|
Scott Ullrich
|
$width = "100%";
|
55 |
42b0c921
|
Phil Davis
|
}
|
56 |
9573d170
|
Scott Ullrich
|
|
57 |
42b0c921
|
Phil Davis
|
if ($_POST['height']) {
|
58 |
9573d170
|
Scott Ullrich
|
$height = $_POST['height'];
|
59 |
42b0c921
|
Phil Davis
|
} else {
|
60 |
f0a3b883
|
Scott Ullrich
|
$height = "200";
|
61 |
42b0c921
|
Phil Davis
|
}
|
62 |
9573d170
|
Scott Ullrich
|
|
63 |
94556105
|
Scott Ullrich
|
// Get configured interface list
|
64 |
61ab4cd3
|
Scott Ullrich
|
$ifdescrs = get_configured_interface_with_descr();
|
65 |
42b0c921
|
Phil Davis
|
if (isset($config['ipsec']['enable'])) {
|
66 |
9f5d14ce
|
jim-p
|
$ifdescrs['enc0'] = "IPsec";
|
67 |
42b0c921
|
Phil Davis
|
}
|
68 |
9f5d14ce
|
jim-p
|
foreach (array('server', 'client') as $mode) {
|
69 |
|
|
if (is_array($config['openvpn']["openvpn-{$mode}"])) {
|
70 |
|
|
foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) {
|
71 |
|
|
if (!isset($setting['disable'])) {
|
72 |
|
|
$ifdescrs['ovpn' . substr($mode, 0, 1) . $setting['vpnid']] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']);
|
73 |
|
|
}
|
74 |
|
|
}
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
43a0ac8a
|
Scott Ullrich
|
|
78 |
e31aa678
|
sbeaver
|
if ($_POST['if']) {
|
79 |
|
|
$curif = $_POST['if'];
|
80 |
50b2f6ab
|
Scott Ullrich
|
$found = false;
|
81 |
6c07db48
|
Phil Davis
|
foreach ($ifdescrs as $descr => $ifdescr) {
|
82 |
b406c78a
|
Ermal
|
if ($descr == $curif) {
|
83 |
|
|
$found = true;
|
84 |
|
|
break;
|
85 |
|
|
}
|
86 |
|
|
}
|
87 |
|
|
if ($found === false) {
|
88 |
6f3d2063
|
Renato Botelho
|
header("Location: status_graph.php");
|
89 |
50b2f6ab
|
Scott Ullrich
|
exit;
|
90 |
|
|
}
|
91 |
|
|
} else {
|
92 |
76165eac
|
Phil Davis
|
if (empty($ifdescrs["wan"])) {
|
93 |
|
|
/* Handle the case when WAN has been disabled. Use the first key in ifdescrs. */
|
94 |
|
|
reset($ifdescrs);
|
95 |
|
|
$curif = key($ifdescrs);
|
96 |
42b0c921
|
Phil Davis
|
} else {
|
97 |
76165eac
|
Phil Davis
|
$curif = "wan";
|
98 |
|
|
}
|
99 |
50b2f6ab
|
Scott Ullrich
|
}
|
100 |
e31aa678
|
sbeaver
|
if ($_POST['sort']) {
|
101 |
|
|
$cursort = $_POST['sort'];
|
102 |
893fb622
|
Michele Di Maria
|
} else {
|
103 |
|
|
$cursort = "";
|
104 |
|
|
}
|
105 |
e31aa678
|
sbeaver
|
if ($_POST['filter']) {
|
106 |
|
|
$curfilter = $_POST['filter'];
|
107 |
da11e022
|
Phil Davis
|
} else {
|
108 |
|
|
$curfilter = "";
|
109 |
|
|
}
|
110 |
e31aa678
|
sbeaver
|
if ($_POST['hostipformat']) {
|
111 |
|
|
$curhostipformat = $_POST['hostipformat'];
|
112 |
4006a437
|
Phil Davis
|
} else {
|
113 |
|
|
$curhostipformat = "";
|
114 |
|
|
}
|
115 |
769cdf3b
|
Bill Marquette
|
|
116 |
e31aa678
|
sbeaver
|
function iflist() {
|
117 |
|
|
global $ifdescrs;
|
118 |
|
|
|
119 |
|
|
$iflist = array();
|
120 |
|
|
|
121 |
|
|
foreach ($ifdescrs as $ifn => $ifd) {
|
122 |
|
|
$iflist[$ifn] = $ifd;
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
return($iflist);
|
126 |
|
|
}
|
127 |
|
|
|
128 |
d0033721
|
Carlos Eduardo Ramos
|
$pgtitle = array(gettext("Status"),gettext("Traffic Graph"));
|
129 |
f0a3b883
|
Scott Ullrich
|
|
130 |
4df96eff
|
Scott Ullrich
|
include("head.inc");
|
131 |
|
|
|
132 |
e31aa678
|
sbeaver
|
require('classes/Form.class.php');
|
133 |
|
|
|
134 |
|
|
$form = new Form(false);
|
135 |
a4af095c
|
Renato Botelho
|
$form->addClass('auto-submit');
|
136 |
e31aa678
|
sbeaver
|
|
137 |
|
|
$section = new Form_Section('Graph settings');
|
138 |
5b237745
|
Scott Ullrich
|
|
139 |
a4af095c
|
Renato Botelho
|
$group = new Form_Group('');
|
140 |
|
|
|
141 |
|
|
$group->add(new Form_Select(
|
142 |
e31aa678
|
sbeaver
|
'if',
|
143 |
a4af095c
|
Renato Botelho
|
null,
|
144 |
e31aa678
|
sbeaver
|
$curif,
|
145 |
|
|
iflist()
|
146 |
a4af095c
|
Renato Botelho
|
))->setHelp('Interface');
|
147 |
e31aa678
|
sbeaver
|
|
148 |
a4af095c
|
Renato Botelho
|
$group->add(new Form_Select(
|
149 |
e31aa678
|
sbeaver
|
'sort',
|
150 |
a4af095c
|
Renato Botelho
|
null,
|
151 |
e31aa678
|
sbeaver
|
$cursort,
|
152 |
|
|
array (
|
153 |
607b1c39
|
Sjon Hortensius
|
'in' => 'Bandwidth In',
|
154 |
|
|
'out' => 'Bandwidth Out'
|
155 |
e31aa678
|
sbeaver
|
)
|
156 |
a4af095c
|
Renato Botelho
|
))->setHelp('Sort by');
|
157 |
e31aa678
|
sbeaver
|
|
158 |
a4af095c
|
Renato Botelho
|
$group->add(new Form_Select(
|
159 |
e31aa678
|
sbeaver
|
'filter',
|
160 |
a4af095c
|
Renato Botelho
|
null,
|
161 |
e31aa678
|
sbeaver
|
$curfilter,
|
162 |
|
|
array (
|
163 |
607b1c39
|
Sjon Hortensius
|
'local' => 'Local',
|
164 |
|
|
'remote'=> 'Remote',
|
165 |
|
|
'all' => 'All'
|
166 |
e31aa678
|
sbeaver
|
)
|
167 |
a4af095c
|
Renato Botelho
|
))->setHelp('Filter');
|
168 |
e31aa678
|
sbeaver
|
|
169 |
a4af095c
|
Renato Botelho
|
$group->add(new Form_Select(
|
170 |
e31aa678
|
sbeaver
|
'hostipformat',
|
171 |
a4af095c
|
Renato Botelho
|
null,
|
172 |
e31aa678
|
sbeaver
|
$curhostipformat,
|
173 |
|
|
array (
|
174 |
607b1c39
|
Sjon Hortensius
|
'' => 'IP Address',
|
175 |
|
|
'hostname' => 'Host Name',
|
176 |
|
|
'fqdn' => 'FQDN'
|
177 |
e31aa678
|
sbeaver
|
)
|
178 |
a4af095c
|
Renato Botelho
|
))->setHelp('Display');
|
179 |
|
|
|
180 |
|
|
$section->add($group);
|
181 |
e31aa678
|
sbeaver
|
|
182 |
|
|
$form->add($section);
|
183 |
|
|
print $form;
|
184 |
|
|
|
185 |
|
|
?>
|
186 |
607b1c39
|
Sjon Hortensius
|
<script>
|
187 |
f0a3b883
|
Scott Ullrich
|
|
188 |
|
|
function updateBandwidth(){
|
189 |
607b1c39
|
Sjon Hortensius
|
$.ajax(
|
190 |
|
|
'/bandwidth_by_ip.php',
|
191 |
|
|
{
|
192 |
|
|
type: 'get',
|
193 |
|
|
data: $(document.forms[0]).serialize(),
|
194 |
|
|
success: function (data) {
|
195 |
|
|
var hosts_split = data.split("|");
|
196 |
|
|
|
197 |
|
|
$('#top10-hosts').empty();
|
198 |
|
|
|
199 |
|
|
//parse top ten bandwidth abuser hosts
|
200 |
|
|
for (var y=0; y<10; y++){
|
201 |
|
|
if ((y < hosts_split.length) && (hosts_split[y] != "") && (hosts_split[y] != "no info")) {
|
202 |
|
|
hostinfo = hosts_split[y].split(";");
|
203 |
|
|
|
204 |
|
|
$('#top10-hosts').append('<tr>'+
|
205 |
|
|
'<td>'+ hostinfo[0] +'</td>'+
|
206 |
|
|
'<td>'+ hostinfo[1] +' Bits/sec</td>'+
|
207 |
|
|
'<td>'+ hostinfo[2] +' Bits/sec</td>'+
|
208 |
|
|
'</tr>');
|
209 |
|
|
}
|
210 |
|
|
}
|
211 |
|
|
},
|
212 |
|
|
});
|
213 |
f0a3b883
|
Scott Ullrich
|
}
|
214 |
|
|
|
215 |
607b1c39
|
Sjon Hortensius
|
events.push(function(){
|
216 |
|
|
$('form.auto-submit').on('change', function(){
|
217 |
|
|
$(this).submit();
|
218 |
|
|
});
|
219 |
f0a3b883
|
Scott Ullrich
|
|
220 |
607b1c39
|
Sjon Hortensius
|
setInterval('updateBandwidth()', 1000);
|
221 |
e31aa678
|
sbeaver
|
|
222 |
607b1c39
|
Sjon Hortensius
|
updateBandwidth();
|
223 |
|
|
});
|
224 |
f0a3b883
|
Scott Ullrich
|
</script>
|
225 |
5b237745
|
Scott Ullrich
|
<?php
|
226 |
9573d170
|
Scott Ullrich
|
|
227 |
872ce0dd
|
Ermal Luçi
|
/* link the ipsec interface magically */
|
228 |
42b0c921
|
Phil Davis
|
if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) {
|
229 |
872ce0dd
|
Ermal Luçi
|
$ifdescrs['enc0'] = "IPsec";
|
230 |
42b0c921
|
Phil Davis
|
}
|
231 |
c1abd446
|
Seth Mos
|
|
232 |
5b237745
|
Scott Ullrich
|
?>
|
233 |
607b1c39
|
Sjon Hortensius
|
<div class="panel panel-default">
|
234 |
|
|
<div class="panel-heading">
|
235 |
|
|
<h2 class="panel-title">Traffic graph</h2>
|
236 |
e31aa678
|
sbeaver
|
</div>
|
237 |
607b1c39
|
Sjon Hortensius
|
<div class="panel-body">
|
238 |
|
|
<div class="col-sm-6">
|
239 |
|
|
<object data="graph.php?ifnum=<?=htmlspecialchars($curif);?>&ifname=<?=rawurlencode($ifdescrs[htmlspecialchars($curif)]);?>">
|
240 |
|
|
<param name="id" value="graph" />
|
241 |
|
|
<param name="type" value="image/svg+xml" />
|
242 |
|
|
<param name="width" value="<? echo $width; ?>" />
|
243 |
|
|
<param name="height" value="<? echo $height; ?>" />
|
244 |
|
|
<param name="pluginspage" value="http://www.adobe.com/svg/viewer/install/auto" />
|
245 |
|
|
</object>
|
246 |
|
|
</div>
|
247 |
|
|
<div class="col-sm-6">
|
248 |
|
|
<table class="table table-striped table-condensed">
|
249 |
|
|
<thead>
|
250 |
|
|
<tr>
|
251 |
|
|
<th><?=(($curhostipformat=="") ? gettext("Host IP") : gettext("Host Name or IP")); ?></th>
|
252 |
|
|
<th><?=gettext("Bandwidth In"); ?></th>
|
253 |
|
|
<th><?=gettext("Bandwidth Out"); ?></th>
|
254 |
|
|
</tr>
|
255 |
|
|
</thead>
|
256 |
|
|
<tbody id="top10-hosts">
|
257 |
|
|
<!-- to be added by javascript -->
|
258 |
|
|
</tbody>
|
259 |
|
|
</table>
|
260 |
|
|
</div>
|
261 |
e57c91a2
|
Renato Botelho
|
</div>
|
262 |
8ab3e9ed
|
Erik Kristensen
|
</div>
|
263 |
607b1c39
|
Sjon Hortensius
|
<?php include("foot.inc");
|