summaryrefslogtreecommitdiffstats
path: root/usr/local/www/bandwidth_by_ip.php
diff options
context:
space:
mode:
authorMichele Di Maria <michele@nt2.it>2012-11-07 08:07:36 +0100
committerMichele Di Maria <michele@nt2.it>2012-11-07 08:07:36 +0100
commit893fb622feffe3590eb1f8de2914ce22376d0696 (patch)
treee8d8158a5dfb38d5ea73b4cd7571bcaa3e226d0d /usr/local/www/bandwidth_by_ip.php
parent9539590cc1094ed44908fe289ff23d1893f64bd7 (diff)
downloadpfsense-893fb622feffe3590eb1f8de2914ce22376d0696.zip
pfsense-893fb622feffe3590eb1f8de2914ce22376d0696.tar.gz
Adds "Sort by direction" in the Traffic Graph page
Added the option to sort IPs by direction in the Traffic Graph page, and improved the detection of the local network to monitor (before the results could not be realistic because of too many "local IPs" were monitored.
Diffstat (limited to 'usr/local/www/bandwidth_by_ip.php')
-rwxr-xr-xusr/local/www/bandwidth_by_ip.php25
1 files changed, 19 insertions, 6 deletions
diff --git a/usr/local/www/bandwidth_by_ip.php b/usr/local/www/bandwidth_by_ip.php
index 71e4c27..ada7209 100755
--- a/usr/local/www/bandwidth_by_ip.php
+++ b/usr/local/www/bandwidth_by_ip.php
@@ -22,12 +22,25 @@ $interface = $_GET['if'];
$real_interface = convert_friendly_interface_to_real_interface_name($interface);
$intip = find_interface_ip($real_interface);
$intip = explode (".", $intip);
-
-//use class A subnet to make sure we capture all traffic on specified interface
-$intsubnet = $intip[0] . ".0.0.0/8";
-
-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);
-
+//get interface netmask
+$netmask = find_interface_subnet($real_interface);
+//get the sort method
+$sort = $_GET['sort'];
+if ($sort == "out")
+ {$sort_method = "-T";}
+else
+ {$sort_method = "-R";}
+//use the same class of the specified interface
+if ($netmask >= 24) {
+ $intsubnet = $intip[0] . "." . $intip[1] . "." . $intip[2] . ".0/24";
+}
+elseif ($netmask >=16){
+ $intsubnet = $intip[0] . "." . $intip[1] . ".0.0/16";
+}
+else {
+ $intsubnet = $intip[0] . ".0.0.0/8";
+}
+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);
unset($bandwidthinfo);
unset($receivebytesarray);
unset($transmitbytesarray);
OpenPOWER on IntegriCloud