dhcp server IP pool monitoring

Chuck Anderson cra at WPI.EDU
Wed Mar 12 19:21:05 UTC 2014


On Wed, Mar 12, 2014 at 09:58:17AM +0200, Mehmet Ali Öksüz wrote:
> Hi Dear Friends,
> 
> we have 3 dhcp servers.
> dhcp-1: Red Hat Enterprise Linux Server release 6.5 (Santiago): dhcp-4.1.1
> dhcp-2: Red Hat Enterprise Linux Server release 6.5 (Santiago): dhcp-4.1.1
> dhcp-3: Debian GNU/Linux 7 (wheezy):  isc-dhcp-server 4.2.6
> 
> we have 75 C Class IPs and 105 subnets (pool) on dhcp servers.
> 
> i'm looking dhcp server IP pool monitoring tool. we tried solarwinds
> IPAM, cacti. but they don't work correctly.
> i found some open source script, i want to monitoring (viewing) IP
> Pools like mrtg, time based and graphical interface
> 
> any ideas?

I'm using a modified dhcpd-snmp package to extend Net-SNMP with a MIB
to export the lease information via SNMP.  The SNMP agent runs on all
my DHCP servers.  Then I use Nagios & Cricket to monitor the DHCP
servers via SNMP.

Here is the source RPM which contains dhcpd-snmp source code along
with the patch I'm using to add failover-related variables to the MIB,
as well as improve the accuracy of how it counts leases.

http://download.wpi.edu/pub/wpi-netops/rhel/6/SRPMS/dhcpd-snmp-0.2-2.el6.src.rpm

It seems that the upstream URL is no longer working:

http://www.net-track.ch/opensource/dhcpd-snmp/

I've also attached my patch to this email, as well as the Nagios
plugin check_dhcp_pool.sh I'm using.

For RHEL/CentOS/Scientific, you will need this custom policy module
for SELinux to allow the snmpd to read the DHCP lease file:

policy_module(dhcpdsnmp, 1.1)

require {
        type dhcpd_state_t;
        type snmpd_t;
        class file { read ioctl open getattr };
}

#============= snmpd_t ==============
allow snmpd_t dhcpd_state_t:file { read ioctl open getattr };

-------------- next part --------------
diff -up dhcpd-snmp-0.2/dhcpd-snmp.in.ext dhcpd-snmp-0.2/dhcpd-snmp.in
--- dhcpd-snmp-0.2/dhcpd-snmp.in.ext	2006-02-14 05:09:47.000000000 -0500
+++ dhcpd-snmp-0.2/dhcpd-snmp.in	2013-09-03 19:57:27.348003666 -0400
@@ -167,6 +167,12 @@ sub create_dhcp_mib
     $dhcp{"2.4.".$i} = [ "integer", $pool->{"active"} ];
     $dhcp{"2.5.".$i} = [ "integer", $pool->{"expired"} ];
     $dhcp{"2.6.".$i} = [ "integer", $pool->{"total"} - $pool->{"active"} ];
+    $dhcp{"2.7.".$i} = [ "integer", $pool->{"bs_active"} ];
+    $dhcp{"2.8.".$i} = [ "integer", $pool->{"bs_free"} ];
+    $dhcp{"2.9.".$i} = [ "integer", $pool->{"bs_backup"} ];
+    $dhcp{"2.10.".$i} = [ "integer", $pool->{"bs_released"} ];
+    $dhcp{"2.11.".$i} = [ "integer", $pool->{"bs_expired"} ];
+    $dhcp{"2.12.".$i} = [ "integer", $pool->{"bs_abandoned"} ];
   }
 
   $mib = \%dhcp;
@@ -191,6 +197,12 @@ sub read_leases
     $conf->{"pools"}->{$i}->{"leases"} = ();
     $conf->{"pools"}->{$i}->{"active"} = 0;
     $conf->{"pools"}->{$i}->{"expired"} = 0;
+    $conf->{"pools"}->{$i}->{"bs_abandoned"} = 0;
+    $conf->{"pools"}->{$i}->{"bs_active"} = 0;
+    $conf->{"pools"}->{$i}->{"bs_backup"} = 0;
+    $conf->{"pools"}->{$i}->{"bs_expired"} = 0;
+    $conf->{"pools"}->{$i}->{"bs_free"} = 0;
+    $conf->{"pools"}->{$i}->{"bs_released"} = 0;
   }
 
   # Read leases
@@ -225,8 +237,11 @@ sub read_leases
       $l{"ends"} = timegm($6, $5, $4, $3, $2-1, $1);
     } elsif (defined %l && $line =~ /^\s+ends never;$/) {
       $l{"ends"} = -1;
+    } elsif (defined %l && $line =~ /^\s+binding state (.*);$/) {
+      $l{"state"} = $1;
     } elsif (defined %l && $line =~ /^\}$/) {
-      $conf->{"pools"}->{$l{"pool"}}->{"leases"}->{$l{"ip"}} = $l{"ends"};
+      $conf->{"pools"}->{$l{"pool"}}->{"leases"}->{$l{"ip"}}->{"ends"} = $l{"ends"};
+      $conf->{"pools"}->{$l{"pool"}}->{"leases"}->{$l{"ip"}}->{"state"} = $l{"state"};
     }
   }
 
@@ -239,12 +254,26 @@ sub read_leases
     my $pool = $conf->{"pools"}->{$i};
 
     foreach my $ip (keys %{ $pool->{"leases"} }) {
-      my $end = $pool->{"leases"}->{$ip};
+      my $end = $pool->{"leases"}->{$ip}->{"ends"};
+      my $state = $pool->{"leases"}->{$ip}->{"state"};
       if (($end == -1) || ($end >= $now)) {
 	$pool->{"active"}++;
       } else {
 	$pool->{"expired"}++;
       }
+      if ($state eq 'abandoned') {
+	  $pool->{"bs_abandoned"}++;
+      } elsif ($state eq 'active') {
+	  $pool->{"bs_active"}++;
+      } elsif ($state eq 'backup') {
+	  $pool->{"bs_backup"}++;
+      } elsif ($state eq 'expired') {
+	  $pool->{"bs_expired"}++;
+      } elsif ($state eq 'free') {
+	  $pool->{"bs_free"}++;
+      } elsif ($state eq 'released') {
+	  $pool->{"bs_released"}++;
+      }
     }
   }
 }
@@ -421,6 +450,12 @@ The script returns the following variabl
   .1.3.6.1.4.1.21695.1.2.4.<pool>: active leases
   .1.3.6.1.4.1.21695.1.2.5.<pool>: expired leases
   .1.3.6.1.4.1.21695.1.2.6.<pool>: available addresses (size - active leases)
+  .1.3.6.1.4.1.21695.1.2.7.<pool>: count of leases in binding state active
+  .1.3.6.1.4.1.21695.1.2.8.<pool>: count of leases in binding state free
+  .1.3.6.1.4.1.21695.1.2.9.<pool>: count of leases in binding state backup
+  .1.3.6.1.4.1.21695.1.2.10.<pool>: count of leases in binding state released
+  .1.3.6.1.4.1.21695.1.2.11.<pool>: count of leases in binding state expired
+  .1.3.6.1.4.1.21695.1.2.12.<pool>: count of leases in binding state abandoned
 
 For a complete MIB file see the C<mibs> directory in the source archive.
 
@@ -433,6 +468,7 @@ information about this.
 =head1 COPYRIGHT AND LICENSE
 
 Copyright (C) 2006 Oliver Hitz
+Copyright (C) 2013 Charles R. Anderson
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
diff -up dhcpd-snmp-0.2/mibs/nettrack-dhcpd-snmp.mib.ext dhcpd-snmp-0.2/mibs/nettrack-dhcpd-snmp.mib
--- dhcpd-snmp-0.2/mibs/nettrack-dhcpd-snmp.mib.ext	2006-02-14 04:02:44.000000000 -0500
+++ dhcpd-snmp-0.2/mibs/nettrack-dhcpd-snmp.mib	2013-09-03 19:57:27.349003666 -0400
@@ -12,7 +12,7 @@ IMPORTS
 
 dhcpdSnmp MODULE-IDENTITY
 	LAST-UPDATED
-		"200601260000Z"
+		"201309030000Z"
 	ORGANIZATION
 		"net-track GmbH"
 	CONTACT-INFO
@@ -28,7 +28,7 @@ dhcpdSnmp MODULE-IDENTITY
 	DESCRIPTION
 		"Management Information for the dhcpd-snmp extension."
 	REVISION
-		"200601260000Z"
+		"201309030000Z"
 	DESCRIPTION
 		"Initial version of this MIB module."
 	::= { public 2 }
@@ -56,7 +56,13 @@ dhcpdSnmpPoolDescription	DisplayString,
 dhcpdSnmpPoolSize		Integer32,
 dhcpdSnmpPoolActiveLeases	Integer32,
 dhcpdSnmpPoolExpiredLeases	Integer32,
-dhcpdSnmpPoolAvailableAddresses	Integer32
+dhcpdSnmpPoolAvailableAddresses	Integer32,
+dhcpdSnmpPoolActiveAddresses	Integer32,
+dhcpdSnmpPoolFreeAddresses	Integer32,
+dhcpdSnmpPoolBackupAddresses	Integer32,
+dhcpdSnmpPoolReleasedAddresses	Integer32,
+dhcpdSnmpPoolExpiredAddresses	Integer32,
+dhcpdSnmpPoolAbandonedAddresses	Integer32
 }
 
 dhcpdSnmpPoolIndex OBJECT-TYPE
@@ -88,7 +94,10 @@ dhcpdSnmpPoolActiveLeases OBJECT-TYPE
 	MAX-ACCESS	read-only
 	STATUS		current
 	DESCRIPTION
-		"Active leases."
+		"Active leases.  This is a count of IP addresses in
+	the pool that are present in the lease database and whose end
+	time hasn't yet been reached.  This represents addresses that
+	are currently assigned to active DHCP clients."
 	::= { dhcpdSnmpPoolTable 4 }
 
 dhcpdSnmpPoolExpiredLeases OBJECT-TYPE
@@ -96,7 +105,10 @@ dhcpdSnmpPoolExpiredLeases OBJECT-TYPE
 	MAX-ACCESS	read-only
 	STATUS		current
 	DESCRIPTION
-		"Expired leases."
+		"Expired leases.  This is a count of IP addresses in
+	the pool that are present in the lease database and whose end
+	time has passed.  This represents addresses that were formerly
+	assigned to DHCP clients, but whose leases have expired."
 	::= { dhcpdSnmpPoolTable 5 }
 
 dhcpdSnmpPoolAvailableAddresses OBJECT-TYPE
@@ -104,7 +116,88 @@ dhcpdSnmpPoolAvailableAddresses OBJECT-T
 	MAX-ACCESS	read-only
 	STATUS		current
 	DESCRIPTION
-		"Available addresses."
+		"Available addresses.  This is equivalent to (pool
+	size - active leases) and represents addresses that are
+	available for assignment to DHCP clients.  Since this does not
+	exclusively count IP addresses present in the lease database,
+	it includes IP addresses that are in the pool but that have
+	not yet been written to the lease database."
 	::= { dhcpdSnmpPoolTable 6 }
 
+dhcpdSnmpPoolActiveAddresses OBJECT-TYPE
+	SYNTAX		Integer32
+	MAX-ACCESS	read-only
+	STATUS		current
+	DESCRIPTION
+		"Leases in binding state 'active'.  This is a count of
+	IP addresses in the pool that are present in the lease
+	database and whose binding state is 'active'.  This should be
+	the same as dhcpdSnmpPoolActiveLeases."
+	::= { dhcpdSnmpPoolTable 7 }
+
+dhcpdSnmpPoolFreeAddresses OBJECT-TYPE
+	SYNTAX		Integer32
+	MAX-ACCESS	read-only
+	STATUS		current
+	DESCRIPTION
+		"Leases in binding state 'free'.  This is a count of
+	IP addresses in the pool that are present in the lease
+	database and whose binding state is 'free'.  For DHCP
+	Failover, this represents IP addresses that are available for
+	assignment by the Primary DHCP server."
+	::= { dhcpdSnmpPoolTable 8 }
+
+dhcpdSnmpPoolBackupAddresses OBJECT-TYPE
+	SYNTAX		Integer32
+	MAX-ACCESS	read-only
+	STATUS		current
+	DESCRIPTION
+		"Leases in binding state 'backup'.  This is a count of
+	IP addresses in the pool that are present in the lease
+	database and whose binding state is 'backup'.  For DHCP
+	Failover, this represents IP addresses that are available for
+	assignment by the Secondary DHCP server."
+	::= { dhcpdSnmpPoolTable 9 }
+
+dhcpdSnmpPoolReleasedAddresses OBJECT-TYPE
+	SYNTAX		Integer32
+	MAX-ACCESS	read-only
+	STATUS		current
+	DESCRIPTION
+		"Leases in binding state 'released'.  This is a count
+	of IP addresses in the pool that are present in the lease
+	database and whose binding state is 'released'.  This
+	represents IP addresses that were released by DHCP clients
+	sending DHCPRELEASE messages to the server.  Leases do not
+	remain in this state--they eventually transition to 'free' or
+	'backup'."
+	::= { dhcpdSnmpPoolTable 10 }
+
+dhcpdSnmpPoolExpiredAddresses OBJECT-TYPE
+	SYNTAX		Integer32
+	MAX-ACCESS	read-only
+	STATUS		current
+	DESCRIPTION
+		"Leases in binding state 'expired'.  This is a count
+	of IP addresses in the pool that are present in the lease
+	database and whose binding state is 'expired'.  Leases do not
+	remain in this state--they eventually transition to 'free' or
+	'backup'."
+	::= { dhcpdSnmpPoolTable 11 }
+
+dhcpdSnmpPoolAbandonedAddresses OBJECT-TYPE
+	SYNTAX		Integer32
+	MAX-ACCESS	read-only
+	STATUS		current
+	DESCRIPTION
+		"Leases in binding state 'abandoned'.  This is a count
+	of IP addresses in the pool that are present in the lease
+	database and whose binding state is 'abandoned'.  This occurs
+	if a DHCP client sends a DHCPDECLINE message or if the DHCP
+	server receives an ICMP Echo response before the address is
+	leased to the client and could indicate that another client is
+	already using the address.  Leases in this state may
+	eventually transition to 'free' or 'backup'."
+	::= { dhcpdSnmpPoolTable 12 }
+
 END
-------------- next part --------------
A non-text attachment was scrubbed...
Name: check_dhcp_pool.sh
Type: application/x-sh
Size: 2472 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20140312/62ba636d/attachment.sh>


More information about the dhcp-users mailing list