summaryrefslogtreecommitdiffstats
path: root/usr/local/www/bandwidth_by_ip.php
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2009-12-25 21:52:46 +0000
committerErmal Luçi <eri@pfsense.org>2009-12-25 21:52:46 +0000
commit6745e860ee13b9456b17cdad4999b6808146ad78 (patch)
treecf6557fd757716025a0060fcced158204115c0ac /usr/local/www/bandwidth_by_ip.php
parent14900201f6719634cda1f719a3c1fe5998bdab83 (diff)
downloadpfsense-6745e860ee13b9456b17cdad4999b6808146ad78.zip
pfsense-6745e860ee13b9456b17cdad4999b6808146ad78.tar.gz
Simplify a lot the code of rate extracting.
Diffstat (limited to 'usr/local/www/bandwidth_by_ip.php')
-rwxr-xr-xusr/local/www/bandwidth_by_ip.php27
1 files changed, 3 insertions, 24 deletions
diff --git a/usr/local/www/bandwidth_by_ip.php b/usr/local/www/bandwidth_by_ip.php
index 8fc29e4..b85db4f 100755
--- a/usr/local/www/bandwidth_by_ip.php
+++ b/usr/local/www/bandwidth_by_ip.php
@@ -30,7 +30,7 @@ $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("rate -i {$real_interface} -nlq 1 -A -c {$intsubnet}", $listedIPs);
+exec("rate -i {$real_interface} -nlq 1 -Aa 10 -c {$intsubnet} | awk '{ printf \"%s:%s:%s:%s:%s\\n\", $1, $2, $5, $8, $11 }'", $listedIPs);
unset($bandwidthinfo);
unset($receivebytesarray);
@@ -44,30 +44,9 @@ for ($x=2; $x<12; $x++){
// echo $bandwidthinfo;
$emptyinfocounter = 1;
if ($bandwidthinfo != "") {
- $splitinfo = explode ("|",$bandwidthinfo);
- $receivebytesarray = explode(" ",$splitinfo[0]);
+ $infoarray = explode (":",$bandwidthinfo);
//print IP of host;
- echo $receivebytesarray[0] . ";";
-
- //skip empty array elements until first element found with data
- while ($receivebytesarray[$emptyinfocounter] == "")
- {
- $emptyinfocounter++;
- }
- //print received bytes for host
- echo $receivebytesarray[$emptyinfocounter] . ";";
-
- $transmitbytesarray = explode(" ",$splitinfo[1]);
-
- $emptyinfocounter = 1;
-
- //skip empty array elements until first element found with data
- while ($transmitbytesarray[$emptyinfocounter] == "")
- {
- $emptyinfocounter++;
- }
- //print transmitted bytes for host
- echo $transmitbytesarray[$emptyinfocounter] . "|";
+ echo $infoarray[0] . ";" . $infoarray[1] . ";" . $infoarray[2] . "|";
//mark that we collected information
$someinfo = true;
OpenPOWER on IntegriCloud