diff options
author | Phil Davis <phil.davis@world.inf.org> | 2014-02-10 02:43:40 -0800 |
---|---|---|
committer | Phil Davis <phil.davis@world.inf.org> | 2014-02-10 02:43:40 -0800 |
commit | 188a4d5586052d5756d3bc2a4248275d71029be0 (patch) | |
tree | 00475edb0cf58e6d2701b339f9b0ca870a728406 | |
parent | 80f5142995ddfabdba4522b168428778d6666541 (diff) | |
download | pfsense-188a4d5586052d5756d3bc2a4248275d71029be0.zip pfsense-188a4d5586052d5756d3bc2a4248275d71029be0.tar.gz |
Return all stats when all or remote is selected on Traffic Graph
and make the default query return "Local" traffic.
-rwxr-xr-x | usr/local/www/bandwidth_by_ip.php | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/usr/local/www/bandwidth_by_ip.php b/usr/local/www/bandwidth_by_ip.php index 0140a74..3bad998 100755 --- a/usr/local/www/bandwidth_by_ip.php +++ b/usr/local/www/bandwidth_by_ip.php @@ -24,10 +24,27 @@ if (!does_interface_exist($real_interface)) { echo gettext("Wrong Interface"); return; } + $intip = find_interface_ip($real_interface); //get interface subnet $netmask = find_interface_subnet($real_interface); $intsubnet = gen_subnet($intip, $netmask) . "/$netmask"; + +// see if they want local, remote or all IPs returned +$filter = $_GET['filter']; + +if ($filter == "") + $filter = "local"; + +if ($filter == "local") { + $ratesubnet = "-c " . $intsubnet; +} else { + // Tell the rate utility to consider the whole internet (0.0.0.0/0) + // and to consider local "l" traffic - i.e. traffic within the whole internet + // then we can filter the resulting output as we wish below. + $ratesubnet = "-lc 0.0.0.0/0"; +} + //get the sort method $sort = $_GET['sort']; if ($sort == "out") @@ -35,8 +52,6 @@ if ($sort == "out") else {$sort_method = "-R";} -$filter = $_GET['filter']; - // get the desired format for displaying the host name or IP $hostipformat = $_GET['hostipformat']; $iplookup = array(); @@ -56,7 +71,7 @@ if (($hostipformat != "") && (!isset($config['dnsmasq']['enable']) || !isset($co } } -$_grb = 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); +$_grb = exec("/usr/local/bin/rate -i {$real_interface} -nlq 1 -Aba 20 {$sort_method} {$ratesubnet} | tr \"|\" \" \" | awk '{ printf \"%s:%s:%s:%s:%s\\n\", $1, $2, $4, $6, $8 }'", $listedIPs); $someinfo = false; for ($x=2; $x<12; $x++){ @@ -67,9 +82,9 @@ for ($x=2; $x<12; $x++){ $emptyinfocounter = 1; if ($bandwidthinfo != "") { $infoarray = explode (":",$bandwidthinfo); - if (($filter == "") || - (($filter == "local") && (ip_in_subnet($infoarray[0], $intsubnet))) || - (($filter == "remote") && (!ip_in_subnet($infoarray[0], $intsubnet)))) { + if (($filter == "all") || + (($filter == "local") && (ip_in_subnet($infoarray[0], $intsubnet))) || + (($filter == "remote") && (!ip_in_subnet($infoarray[0], $intsubnet)))) { if ($hostipformat == "") { $addrdata = $infoarray[0]; } else { @@ -93,7 +108,7 @@ for ($x=2; $x<12; $x++){ //mark that we collected information $someinfo = true; } - } + } } unset($bandwidthinfo, $_grb); unset($listedIPs); |