summaryrefslogtreecommitdiffstats
path: root/src/usr/local/bin
diff options
context:
space:
mode:
authorheper <heper@users.noreply.github.com>2015-11-10 19:43:18 +0100
committerheper <heper@users.noreply.github.com>2015-11-10 19:43:18 +0100
commitbd0d21939fd4da9bb79d5f16e2776a9253cffd40 (patch)
tree36a386b73e7389d15e26800e75f97197e61f812a /src/usr/local/bin
parent796b7651bc3658a90c3918e2c28db8766501be4e (diff)
downloadpfsense-bd0d21939fd4da9bb79d5f16e2776a9253cffd40.zip
pfsense-bd0d21939fd4da9bb79d5f16e2776a9253cffd40.tar.gz
add dhcp-range
Diffstat (limited to 'src/usr/local/bin')
-rw-r--r--src/usr/local/bin/dhcpd_gather_stats.php18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/usr/local/bin/dhcpd_gather_stats.php b/src/usr/local/bin/dhcpd_gather_stats.php
index 128fe0f..59e9045 100644
--- a/src/usr/local/bin/dhcpd_gather_stats.php
+++ b/src/usr/local/bin/dhcpd_gather_stats.php
@@ -28,12 +28,14 @@ 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]])) {
- $leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases";
+ $leasesfile = "{$g['dhcpd_chroot_path']}/var/db/dhcpd.leases.fake";
$leases_contents = file($leasesfile);
$dhcpif = $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'] ;
OpenPOWER on IntegriCloud