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