summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xusr/local/www/bandwidth_by_ip.php25
-rwxr-xr-xusr/local/www/status_graph.php17
2 files changed, 33 insertions, 9 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);
diff --git a/usr/local/www/status_graph.php b/usr/local/www/status_graph.php
index bbe3a66..7f59cb3 100755
--- a/usr/local/www/status_graph.php
+++ b/usr/local/www/status_graph.php
@@ -81,6 +81,11 @@ if ($_GET['if']) {
} else {
$curif = "wan";
}
+if ($_GET['sort']) {
+ $cursort = $_GET['sort'];
+} else {
+ $cursort = "";
+}
$pgtitle = array(gettext("Status"),gettext("Traffic Graph"));
@@ -94,11 +99,12 @@ include("head.inc");
function updateBandwidth(){
var hostinterface = "<?php echo htmlspecialchars($curif); ?>";
- bandwidthAjax(hostinterface);
+ var sorting = "<?php echo htmlspecialchars($cursort); ?>";
+ bandwidthAjax(hostinterface, sorting);
}
-function bandwidthAjax(hostinterface) {
- uri = "bandwidth_by_ip.php?if=" + hostinterface;
+function bandwidthAjax(hostinterface, sorting) {
+ uri = "bandwidth_by_ip.php?if=" + hostinterface + "&sort=" + sorting;
var opt = {
// Use GET
type: 'get',
@@ -184,6 +190,11 @@ foreach ($ifdescrs as $ifn => $ifd) {
}
?>
</select>
+, Sort by:
+<select name="sort" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
+ <option value="">Bandwidth In</option>
+ <option value="out"<?php if ($cursort == "out") echo " selected";?>>Bandwidth Out</option>
+</select>
</form>
<p><form method="post" action="status_graph.php">
</form>
OpenPOWER on IntegriCloud