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
|
|
26
|
//use class A subnet to make sure we capture all traffic on specified interface
|
27
|
$intsubnet = $intip[0] . ".0.0.0/8";
|
28
|
|
29
|
exec("/usr/local/bin/rate -i {$real_interface} -nlq 1 -Aba 20 -c {$intsubnet} | tr \"|\" \" \" | awk '{ printf \"%s:%s:%s:%s:%s\\n\", $1, $2, $4, $6, $8 }'", $listedIPs);
|
30
|
|
31
|
unset($bandwidthinfo);
|
32
|
unset($receivebytesarray);
|
33
|
unset($transmitbytesarray);
|
34
|
|
35
|
$someinfo = false;
|
36
|
for ($x=2; $x<12; $x++){
|
37
|
|
38
|
$bandwidthinfo = $listedIPs[$x];
|
39
|
|
40
|
// echo $bandwidthinfo;
|
41
|
$emptyinfocounter = 1;
|
42
|
if ($bandwidthinfo != "") {
|
43
|
$infoarray = explode (":",$bandwidthinfo);
|
44
|
//print IP of host;
|
45
|
echo $infoarray[0] . ";" . $infoarray[1] . ";" . $infoarray[2] . "|";
|
46
|
|
47
|
//mark that we collected information
|
48
|
$someinfo = true;
|
49
|
}
|
50
|
}
|
51
|
|
52
|
//no bandwidth usage found
|
53
|
if ($someinfo == false)
|
54
|
echo gettext("no info");
|
55
|
|
56
|
?>
|