1 |
f0a3b883
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
* To change this template, choose Tools | Templates
|
4 |
|
|
* and open the template in the editor.
|
5 |
|
|
*
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
13d193c2
|
Scott Ullrich
|
/*
|
9 |
|
|
pfSense_BUILDER_BINARIES: /usr/local/bin/rate
|
10 |
|
|
pfSense_MODULE: trafficgraph
|
11 |
|
|
*/
|
12 |
|
|
|
13 |
f0a3b883
|
Scott Ullrich
|
require_once('guiconfig.inc');
|
14 |
|
|
require_once('interfaces.inc');
|
15 |
|
|
require_once('pfsense-utils.inc');
|
16 |
|
|
require_once('util.inc');
|
17 |
|
|
|
18 |
|
|
$listedIPs = "";
|
19 |
|
|
|
20 |
|
|
//get interface IP and break up into an array
|
21 |
|
|
$interface = $_GET['if'];
|
22 |
|
|
$real_interface = convert_friendly_interface_to_real_interface_name($interface);
|
23 |
|
|
$intip = find_interface_ip($real_interface);
|
24 |
|
|
$intip = explode (".", $intip);
|
25 |
893fb622
|
Michele Di Maria
|
//get interface netmask
|
26 |
|
|
$netmask = find_interface_subnet($real_interface);
|
27 |
|
|
//get the sort method
|
28 |
|
|
$sort = $_GET['sort'];
|
29 |
|
|
if ($sort == "out")
|
30 |
|
|
{$sort_method = "-T";}
|
31 |
|
|
else
|
32 |
|
|
{$sort_method = "-R";}
|
33 |
|
|
//use the same class of the specified interface
|
34 |
|
|
if ($netmask >= 24) {
|
35 |
|
|
$intsubnet = $intip[0] . "." . $intip[1] . "." . $intip[2] . ".0/24";
|
36 |
|
|
}
|
37 |
|
|
elseif ($netmask >=16){
|
38 |
|
|
$intsubnet = $intip[0] . "." . $intip[1] . ".0.0/16";
|
39 |
|
|
}
|
40 |
|
|
else {
|
41 |
|
|
$intsubnet = $intip[0] . ".0.0.0/8";
|
42 |
|
|
}
|
43 |
|
|
exec("/usr/local/bin/rate -i {$real_interface} -nlq 1 -Aba 20 {$sort_method} -c {$intsubnet} | tr \"|\" \" \" | awk '{ printf \"%s:%s:%s:%s:%s\\n\", $1, $2, $4, $6, $8 }'", $listedIPs);
|
44 |
f0a3b883
|
Scott Ullrich
|
unset($bandwidthinfo);
|
45 |
|
|
unset($receivebytesarray);
|
46 |
|
|
unset($transmitbytesarray);
|
47 |
|
|
|
48 |
|
|
$someinfo = false;
|
49 |
|
|
for ($x=2; $x<12; $x++){
|
50 |
|
|
|
51 |
|
|
$bandwidthinfo = $listedIPs[$x];
|
52 |
|
|
|
53 |
|
|
// echo $bandwidthinfo;
|
54 |
|
|
$emptyinfocounter = 1;
|
55 |
|
|
if ($bandwidthinfo != "") {
|
56 |
6745e860
|
Ermal Lu?i
|
$infoarray = explode (":",$bandwidthinfo);
|
57 |
f0a3b883
|
Scott Ullrich
|
//print IP of host;
|
58 |
6745e860
|
Ermal Lu?i
|
echo $infoarray[0] . ";" . $infoarray[1] . ";" . $infoarray[2] . "|";
|
59 |
f0a3b883
|
Scott Ullrich
|
|
60 |
|
|
//mark that we collected information
|
61 |
|
|
$someinfo = true;
|
62 |
|
|
}
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
//no bandwidth usage found
|
66 |
|
|
if ($someinfo == false)
|
67 |
a1129192
|
Carlos Eduardo Ramos
|
echo gettext("no info");
|
68 |
f0a3b883
|
Scott Ullrich
|
|
69 |
|
|
?>
|