diff options
author | Ermal Luçi <ermal.luci@gmail.com> | 2012-11-06 23:45:12 -0800 |
---|---|---|
committer | Ermal Luçi <ermal.luci@gmail.com> | 2012-11-06 23:45:12 -0800 |
commit | 34811aa7c0c0d411eb3b733c850964a72eb1c50c (patch) | |
tree | e8d8158a5dfb38d5ea73b4cd7571bcaa3e226d0d | |
parent | 9539590cc1094ed44908fe289ff23d1893f64bd7 (diff) | |
parent | 893fb622feffe3590eb1f8de2914ce22376d0696 (diff) | |
download | pfsense-34811aa7c0c0d411eb3b733c850964a72eb1c50c.zip pfsense-34811aa7c0c0d411eb3b733c850964a72eb1c50c.tar.gz |
Merge pull request #247 from mdima/master
Adds "Sort by direction" in the Traffic Graph page
-rwxr-xr-x | usr/local/www/bandwidth_by_ip.php | 25 | ||||
-rwxr-xr-x | usr/local/www/status_graph.php | 17 |
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> |