1
|
<?php
|
2
|
/*
|
3
|
* To change this template, choose Tools | Templates
|
4
|
* and open the template in the editor.
|
5
|
*
|
6
|
*/
|
7
|
|
8
|
/*
|
9
|
pfSense_BUILDER_BINARIES: /usr/local/bin/rate
|
10
|
pfSense_MODULE: trafficgraph
|
11
|
*/
|
12
|
|
13
|
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
|
//get interface subnet
|
26
|
$netmask = find_interface_subnet($real_interface);
|
27
|
$intsubnet = gen_subnet(find_interface_ip($real_interface), $netmask) . "/$netmask";
|
28
|
//get the sort method
|
29
|
$sort = $_GET['sort'];
|
30
|
if ($sort == "out")
|
31
|
{$sort_method = "-T";}
|
32
|
else
|
33
|
{$sort_method = "-R";}
|
34
|
|
35
|
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);
|
36
|
unset($bandwidthinfo);
|
37
|
unset($receivebytesarray);
|
38
|
unset($transmitbytesarray);
|
39
|
|
40
|
$someinfo = false;
|
41
|
for ($x=2; $x<12; $x++){
|
42
|
|
43
|
$bandwidthinfo = $listedIPs[$x];
|
44
|
|
45
|
// echo $bandwidthinfo;
|
46
|
$emptyinfocounter = 1;
|
47
|
if ($bandwidthinfo != "") {
|
48
|
$infoarray = explode (":",$bandwidthinfo);
|
49
|
//print IP of host;
|
50
|
echo $infoarray[0] . ";" . $infoarray[1] . ";" . $infoarray[2] . "|";
|
51
|
|
52
|
//mark that we collected information
|
53
|
$someinfo = true;
|
54
|
}
|
55
|
}
|
56
|
|
57
|
//no bandwidth usage found
|
58
|
if ($someinfo == false)
|
59
|
echo gettext("no info");
|
60
|
|
61
|
?>
|