ISC DHCPD status report generator
After setting up my apartment’s OpenBSD based network, I decided it would be handy to have a simple report generator to describe active DHCPD leases. I also wanted to brush up on Perl a bit. This Perl script is the natural result of such circumstances.
Run dhcpd-report.pl to generate a plaintext or HTML report of current leases in the DHCPD lease database and reservations in dhcpd.conf. In my usage, I have the script set to run once every five minutes in a cron job, sending output to an HTML file in a web server document root. (On OpenBSD, httpd runs in a chroot jail; if I were to run this script as CGI it wouldn’t have direct access to the DHCPD configuration files.) Thus the script can be used to give you a reasonably up to date web page displaying your network’s DHCP clients.
By default, the program looks for dhcpd.leases and dhcpd.conf in /var/db/ and /etc/, respectively, which are these files’ locations in OpenBSD 4.1. If needed, you can change where the script looks for these files by modifying a pair of constants near the top of the main program.
dhcpd-report.pl requires the Date::Format and Date::Parse modules from CPAN. See the POD documentation* for more info.
Download: dhcpd-report.pl
*Sort of like an ATM machine or a PIN number…
3 Responses to ISC DHCPD status report generator
Hi,
when i save this perl-script in /usr/bin
can i make the html output to /var/www/dhcpleases/index.html ?
what must i change in the script for this to do?
with best wishes.
uwe
@Uwe:
For that you don’t need to change the script, just the arguments that you pass to it. E.g., running this as
should do what you want, as long as the user you run the script under has permission to write to that directory.
Nice script. I had to make some changes to the lease parsing to make it work on my centos box, let me know if you want the diffs. Also, the uid in my logs is some inconsistent quoted pseudo decimal encoded hex nonsense that your secript doesnt even begin to match, I just made it match anything and ignore it.
What Im really wanting to see though is a daily report indicating what reserved ip’s had been used so I can weed out some of the obsolete reservations. We as a matter of policy reserve everything, and have a very small dynamic pool which your script will help show me when someone uses it so I can create a reservation for them.