summaryrefslogtreecommitdiffstats
path: root/usr/local/www/bandwidth_by_ip.php
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@sullrich-MacBookPro.geekgod.com>2009-06-15 19:06:29 -0400
committerScott Ullrich <sullrich@sullrich-MacBookPro.geekgod.com>2009-06-15 19:06:53 -0400
commitf0a3b883e64692edea9f8332ee6ba361e28b66f8 (patch)
tree5940d43866f81cf2e6c0a060d556a18a90937056 /usr/local/www/bandwidth_by_ip.php
parent2f3446dba97007c6446f6fe8e079c5ef3874fef1 (diff)
downloadpfsense-f0a3b883e64692edea9f8332ee6ba361e28b66f8.zip
pfsense-f0a3b883e64692edea9f8332ee6ba361e28b66f8.tar.gz
Adding Scott Dale's rate package to system -> traffic graphs. Cool stuff!
Diffstat (limited to 'usr/local/www/bandwidth_by_ip.php')
-rwxr-xr-xusr/local/www/bandwidth_by_ip.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/usr/local/www/bandwidth_by_ip.php b/usr/local/www/bandwidth_by_ip.php
new file mode 100755
index 0000000..3fd01a6
--- /dev/null
+++ b/usr/local/www/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";
+
+?>
OpenPOWER on IntegriCloud