summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorChris Buechler <cmb@pfsense.org>2013-03-06 21:20:13 -0800
committerChris Buechler <cmb@pfsense.org>2013-03-06 21:20:13 -0800
commit379ec2f74ee78e3db7a705741a665f1786d0277b (patch)
tree1a5fd91c2cda54e64bf9d66a28a2fae1ff074691 /usr
parent2158b1cef072e0f89fa0120fe6b57e4921480ab4 (diff)
parent8389a461a6ddba8414682fc814db36077dd1a590 (diff)
downloadpfsense-379ec2f74ee78e3db7a705741a665f1786d0277b.zip
pfsense-379ec2f74ee78e3db7a705741a665f1786d0277b.tar.gz
Merge pull request #464 from phil-davis/master
Add display by host name option to Traffic Graph
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/bandwidth_by_ip.php40
-rwxr-xr-xusr/local/www/status_graph.php20
2 files changed, 54 insertions, 6 deletions
diff --git a/usr/local/www/bandwidth_by_ip.php b/usr/local/www/bandwidth_by_ip.php
index 5c46912..f14af21 100755
--- a/usr/local/www/bandwidth_by_ip.php
+++ b/usr/local/www/bandwidth_by_ip.php
@@ -35,6 +35,25 @@ if ($sort == "out")
else
{$sort_method = "-R";}
+// get the desired format for displaying the host name or IP
+$hostipformat = $_GET['hostipformat'];
+$iplookup = array();
+// If hostname display is requested and the DNS forwarder does not already have DHCP static names registered,
+// then load the DHCP static mappings into an array keyed by IP address.
+if (($hostipformat == "hostname") && (!isset($config['dnsmasq']['regdhcpstatic']))) {
+ if (is_array($config['dhcpd'])) {
+ foreach ($config['dhcpd'] as $ifdata) {
+ if (is_array($ifdata['staticmap'])) {
+ foreach ($ifdata['staticmap'] as $hostent) {
+ if (($hostent['ipaddr'] != "") && ($hostent['hostname'] != "")) {
+ $iplookup[$hostent['ipaddr']] = $hostent['hostname'];
+ }
+ }
+ }
+ }
+ }
+}
+
$_grb = 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);
$someinfo = false;
@@ -46,8 +65,25 @@ for ($x=2; $x<12; $x++){
$emptyinfocounter = 1;
if ($bandwidthinfo != "") {
$infoarray = explode (":",$bandwidthinfo);
- //print IP of host;
- echo $infoarray[0] . ";" . $infoarray[1] . ";" . $infoarray[2] . "|";
+ if ($hostipformat == "") {
+ $addrdata = $infoarray[0];
+ } else {
+ // $hostipformat is "hostname" or "fqdn"
+ $addrdata = gethostbyaddr($infoarray[0]);
+ if ($addrdata == $infoarray[0]) {
+ // gethostbyaddr() gave us back the IP address, so try the static mapping array
+ if ($iplookup[$infoarray[0]] != "")
+ $addrdata = $iplookup[$infoarray[0]];
+ } else {
+ if ($hostipformat == "hostname") {
+ // Only pass back the first part of the name, not the FQDN.
+ $name_array = explode(".", $addrdata);
+ $addrdata = $name_array[0];
+ }
+ }
+ }
+ //print host information;
+ echo $addrdata . ";" . $infoarray[1] . ";" . $infoarray[2] . "|";
//mark that we collected information
$someinfo = true;
diff --git a/usr/local/www/status_graph.php b/usr/local/www/status_graph.php
index 04f91a5..ec7b73d 100755
--- a/usr/local/www/status_graph.php
+++ b/usr/local/www/status_graph.php
@@ -97,6 +97,11 @@ if ($_GET['sort']) {
} else {
$cursort = "";
}
+if ($_GET['hostipformat']) {
+ $curhostipformat = $_GET['hostipformat'];
+} else {
+ $curhostipformat = "";
+}
$pgtitle = array(gettext("Status"),gettext("Traffic Graph"));
@@ -111,11 +116,12 @@ include("head.inc");
function updateBandwidth(){
var hostinterface = jQuery("#if").val();
var sorting = jQuery("#sort").val();
- bandwidthAjax(hostinterface, sorting);
+ var hostipformat = jQuery("#hostipformat").val();
+ bandwidthAjax(hostinterface, sorting, hostipformat);
}
-function bandwidthAjax(hostinterface, sorting) {
- uri = "bandwidth_by_ip.php?if=" + hostinterface + "&sort=" + sorting;
+function bandwidthAjax(hostinterface, sorting, hostipformat) {
+ uri = "bandwidth_by_ip.php?if=" + hostinterface + "&sort=" + sorting + "&hostipformat=" + hostipformat;
var opt = {
// Use GET
type: 'get',
@@ -208,6 +214,12 @@ foreach ($ifdescrs as $ifn => $ifd) {
<option value="">Bandwidth In</option>
<option value="out"<?php if ($cursort == "out") echo " selected";?>>Bandwidth Out</option>
</select>
+, Display:
+<select id="hostipformat" name="hostipformat" class="formselect" style="z-index: -10;" onchange="document.form1.submit()">
+ <option value="">IP Address</option>
+ <option value="hostname"<?php if ($curhostipformat == "hostname") echo " selected";?>>Host Name</option>
+ <option value="fqdn"<?php if ($curhostipformat == "fqdn") echo " selected";?>>FQDN</option>
+</select>
</form>
<p>
<div id="niftyOutter">
@@ -217,7 +229,7 @@ foreach ($ifdescrs as $ifn => $ifd) {
<div id="col2" style="float: right; width: 48%; padding: 5px; position: relative;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
- <td class="listtopic" valign="top"><?=gettext("Host IP"); ?></td>
+ <td class="listtopic" valign="top"><?=(($curhostipformat=="") ? gettext("Host IP") : gettext("Host Name or IP")); ?></td>
<td class="listtopic" valign="top"><?=gettext("Bandwidth In"); ?></td>
<td class="listtopic" valign="top"><?=gettext("Bandwidth Out"); ?></td>
</tr>
OpenPOWER on IntegriCloud