diff options
author | jim-p <jim@pingle.org> | 2009-06-13 22:58:40 -0400 |
---|---|---|
committer | jim-p <jim@pingle.org> | 2009-06-13 22:59:37 -0400 |
commit | 866e8caab3c18c5a65bb428521db378e198f4c9a (patch) | |
tree | f1ce54ad970da4e1e4e523554ab8c4e10de97930 /config/rate/bandwidth_by_ip.php | |
parent | 81065c240f0e0f2b05b77bd49eb69b152b4105a9 (diff) | |
download | pfsense-packages-866e8caab3c18c5a65bb428521db378e198f4c9a.tar.gz pfsense-packages-866e8caab3c18c5a65bb428521db378e198f4c9a.tar.bz2 pfsense-packages-866e8caab3c18c5a65bb428521db378e198f4c9a.zip |
Add rate package, courtesy of Scott Dale
Diffstat (limited to 'config/rate/bandwidth_by_ip.php')
-rw-r--r-- | config/rate/bandwidth_by_ip.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/config/rate/bandwidth_by_ip.php b/config/rate/bandwidth_by_ip.php new file mode 100644 index 00000000..3fd01a61 --- /dev/null +++ b/config/rate/bandwidth_by_ip.php @@ -0,0 +1,77 @@ +<?php +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + * + * + * + * + * + */ + +require_once('guiconfig.inc'); +require_once('interfaces.inc'); +require_once('pfsense-utils.inc'); +require_once('util.inc'); + +$listedIPs = ""; + +//get interface IP and break up into an array +$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("rate -i {$real_interface} -nlq 1 -A -c {$intsubnet}", $listedIPs); + +unset($bandwidthinfo); +unset($receivebytesarray); +unset($transmitbytesarray); + +$someinfo = false; +for ($x=2; $x<12; $x++){ + + $bandwidthinfo = $listedIPs[$x]; + + // echo $bandwidthinfo; + $emptyinfocounter = 1; + if ($bandwidthinfo != "") { + $splitinfo = explode ("|",$bandwidthinfo); + $receivebytesarray = explode(" ",$splitinfo[0]); + //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] . "|"; + + //mark that we collected information + $someinfo = true; + } +} + + +//no bandwidth usage found +if ($someinfo == false) + echo "no info"; + +?> |