diff options
author | Stephen Beaver <sbeaver@netgate.com> | 2015-11-11 12:59:19 -0500 |
---|---|---|
committer | Stephen Beaver <sbeaver@netgate.com> | 2015-11-11 12:59:19 -0500 |
commit | 2778bea576896b7694c98fb02b336a6393e55943 (patch) | |
tree | 0a6e57254d065f819f44435234129bd87f630efe | |
parent | 670a9045695426697328fb91c64624b6234f02ba (diff) | |
parent | 7617e69572ef7ee4c476f6850a41cae6fb82a019 (diff) | |
download | pfsense-2778bea576896b7694c98fb02b336a6393e55943.zip pfsense-2778bea576896b7694c98fb02b336a6393e55943.tar.gz |
Merge pull request #2054 from heper/patch-1
-rw-r--r-- | src/etc/inc/rrd.inc | 2 | ||||
-rw-r--r-- | src/usr/local/bin/dhcpd_gather_stats.php | 16 | ||||
-rw-r--r-- | src/usr/local/www/status_rrd_graph_img.php | 20 |
3 files changed, 26 insertions, 12 deletions
diff --git a/src/etc/inc/rrd.inc b/src/etc/inc/rrd.inc index 0c05062..5f7ac73 100644 --- a/src/etc/inc/rrd.inc +++ b/src/etc/inc/rrd.inc @@ -1,4 +1,5 @@ <?php +/* $Id$ */ /* rrd.inc Copyright (C) 2010 Seth Mos <seth.mos@dds.nl> @@ -922,6 +923,7 @@ function enable_rrd_graphing() { $rrdcreate = "$rrdtool create $rrddbpath$dhcpif$dhcpd --step $rrddhcpdinterval "; $rrdcreate .= "DS:leases:GAUGE:$dhcpdvalid:0:100000 "; $rrdcreate .= "DS:staticleases:GAUGE:$dhcpdvalid:0:100000 "; + $rrdcreate .= "DS:dhcprange:GAUGE:$dhcpdvalid:0:100000 "; $rrdcreate .= "RRA:MIN:0.5:1:1200 "; $rrdcreate .= "RRA:MIN:0.5:5:720 "; $rrdcreate .= "RRA:MIN:0.5:60:1860 "; diff --git a/src/usr/local/bin/dhcpd_gather_stats.php b/src/usr/local/bin/dhcpd_gather_stats.php index 128fe0f..b16e887 100644 --- a/src/usr/local/bin/dhcpd_gather_stats.php +++ b/src/usr/local/bin/dhcpd_gather_stats.php @@ -28,8 +28,10 @@ require_once("config.inc"); require("interfaces.inc"); /* echo the rrd required syntax */ echo "N:"; -$result = "NaN"; -$result_static="NaN"; +$result = array(); +$result['active'] = "NaN"; +$result['static'] ="NaN"; +$result['range'] ="NaN"; if (is_array($config['dhcpd'][$argv[1]])) { @@ -187,7 +189,9 @@ if (is_array($config['dhcpd'][$argv[1]])) { $ifcfgsn = get_interface_subnet($dhcpif); $subnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn))); $subnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | (~gen_subnet_mask_long($ifcfgsn)))); - + + $result['range'] = (ip2ulong($config['dhcpd'][$dhcpif]['range']['to'])) - (ip2ulong($config['dhcpd'][$dhcpif]['range']['from'])) ; + foreach ($leases as $data) { $lip = ip2ulong($data['ip']); @@ -195,14 +199,14 @@ if (is_array($config['dhcpd'][$argv[1]])) { continue; if ($data['act'] != "static") { if (($lip >= ip2ulong($config['dhcpd'][$dhcpif]['range']['from'])) && ($lip <= ip2ulong($config['dhcpd'][$dhcpif]['range']['to']))) { - $result = $result + 1; + $result['active'] = $result['active'] + 1; } } else { if (($lip >= $subnet_start) && ($lip <= $subnet_end)) { - $result_static = $result_static + 1; + $result['static'] = $result['static'] + 1; } } } } -echo "$result:$result_static" ; +echo $result['active'].":".$result['static'].":".$result['range'] ; diff --git a/src/usr/local/www/status_rrd_graph_img.php b/src/usr/local/www/status_rrd_graph_img.php index 4c789a1..0e7a0eb 100644 --- a/src/usr/local/www/status_rrd_graph_img.php +++ b/src/usr/local/www/status_rrd_graph_img.php @@ -1,4 +1,5 @@ <?php +/* $Id$ */ /* status_rrd_graph_img.php */ @@ -284,7 +285,7 @@ $colorntpd = array('0080FF', '00E344', 'FF0000', '000000'); /* Captive Portal Concurrent Concurrent Users */ $colorcaptiveportalusers = array('990000'); -$colordhcpd = array('990000', '0000FF'); +$colordhcpd = array('990000', '0000FF', '000000'); switch ($curstyle) { case "absolute": @@ -1245,20 +1246,27 @@ if ((strstr($curdatabase, "-traffic.rrd")) && (file_exists("$rrddbpath$curdataba $graphcmd .= "--height 200 --width 620 "; $graphcmd .= "DEF:\"$curif-leases=$rrddbpath$curdatabase:leases:AVERAGE:step=$step\" "; $graphcmd .= "DEF:\"$curif-staticleases=$rrddbpath$curdatabase:staticleases:AVERAGE:step=$step\" "; - $graphcmd .= "LINE1:\"$curif-leases#{$colordhcpd[0]}:Active Leases\" "; - $graphcmd .= "LINE1:\"$curif-staticleases#{$colordhcpd[1]}:Static Leases\" "; + $graphcmd .= "DEF:\"$curif-dhcprange=$rrddbpath$curdatabase:dhcprange:AVERAGE:step=$step\" "; + $graphcmd .= "AREA:\"$curif-leases#{$colordhcpd[0]}:Active Leases\" "; + $graphcmd .= "LINE2:\"$curif-staticleases#{$colordhcpd[1]}:Static Leases\" "; + $graphcmd .= "LINE1:\"$curif-dhcprange#{$colordhcpd[2]}:Dhcp Range\" "; $graphcmd .= "COMMENT:\"\\n\" "; - $graphcmd .= "COMMENT:\"\t\t\t current\t\t average\t maximum\\n\" "; - $graphcmd .= "COMMENT:\"Leases Active\t\" "; + $graphcmd .= "COMMENT:\"\t\t\t current\t\t average\t\tmaximum\\n\" "; + $graphcmd .= "COMMENT:\"Active Leases\t\" "; $graphcmd .= "GPRINT:\"$curif-leases:LAST:%8.0lf \" "; $graphcmd .= "GPRINT:\"$curif-leases:AVERAGE:%8.0lf \" "; $graphcmd .= "GPRINT:\"$curif-leases:MAX:%8.0lf \" "; $graphcmd .= "COMMENT:\"\\n\" "; - $graphcmd .= "COMMENT:\"Leases Static\t\" "; + $graphcmd .= "COMMENT:\"Static Leases\t\" "; $graphcmd .= "GPRINT:\"$curif-staticleases:LAST:%8.0lf \" "; $graphcmd .= "GPRINT:\"$curif-staticleases:AVERAGE:%8.0lf \" "; $graphcmd .= "GPRINT:\"$curif-staticleases:MAX:%8.0lf \" "; $graphcmd .= "COMMENT:\"\\n\" "; + $graphcmd .= "COMMENT:\"Dhcp Range\t\t\" "; + $graphcmd .= "GPRINT:\"$curif-dhcprange:LAST:%8.0lf \" "; + $graphcmd .= "GPRINT:\"$curif-dhcprange:AVERAGE:%8.0lf \" "; + $graphcmd .= "GPRINT:\"$curif-dhcprange:MAX:%8.0lf \" "; + $graphcmd .= "COMMENT:\"\\n\" "; $graphcmd .= "COMMENT:\"\t\t\t\t\t\t\t\t\t\t\t\t\t" . strftime('%b %d %H\:%M\:%S %Y') . "\" "; } else { $data = false; |