Skip to content
Extension for monitoring the ISC DHCP server with SNMP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.





$ dhcpd-snmp [--test] dhcpd-snmp.conf


dhcpd-snmp is an extension for the Net-SNMP agent and the ISC DHCP server. It allows you to monitor and track the address usage of your dynamic IP address pools through SNMP.


The configuration file defines the location of the dhcpd.leases file as well as the pools of which you want to access the lease counts.

The file is in key: value format and allows only two keys:

leases: /var/lib/dhcp3/dhcpd.leases

Location of the dhcpd.leases file. This file needs to be accessible by the script.

pool: index, description, ip1-ip2, ip3-ip4...

Defines a pool to monitor. index is a unique numeric index, description a textual description of this pool, and ip1-ip2, ip3-ip4, ... defines the ranges of IP addresses belonging to this pool.

Since this extension is a persistent script, changes to the configuration file require a restart of snmpd.


After installing the dhcpd-snmp script and adapting the configuration file, test if the configuration is valid:

$ path/to/dhcpd-snmp --test path/to/dhcpd-snmp.conf

This will print per-pool stats.

If this works, it can be installed in Net-SNMP. To install it, the following line needs to be inserted in the snmpd.conf file:

pass_persist . path/to/dhcpd-snmp path/to/dhcpd-snmp.conf

Net-SNMP will need to be restarted after this change.

You should now be able to get the statistics using snmpwalk, for example:

$ snmpwalk host community .

This should give you a list of the statistics of your DHCP server.


dhcpd-snmp is a simple script which is run by Net-SNMP and which is controlled using stdin/stdout. If you run it interactively, you can control it as follows:


The script should return "PONG".


The script should return three lines: the OID, "integer", and the number of configured pools.


OID, "string", and the name of your first address pool.


OID, "integer", and the number of active leases.

Quit the dialog using CTRL-D.


The script returns the following variables:

. number of configured pools
.<pool>: pool description
.<pool>: size of the pool (number of addresses)
.<pool>: active leases
.<pool>: expired leases
.<pool>: available addresses (size - active leases)

For a complete MIB file see the mibs directory in the source archive.


It is assumed that users of this script know how to properly secure their snmpd. Please read the corresponding man pages on more information about this.


Copyright (C) 2006-2015 Oliver Hitz

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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

You can’t perform that action at this time.