parsing dhcpd.leases file

sthaug at nethelp.no sthaug at nethelp.no
Wed Apr 15 18:20:06 UTC 2009


> I avoid all that complexity and simply parse the whole file, all 30 megabytes or do (about 12k active leases at the moment) once every 2 minutes on each one of my 3.0.x partner pair servers.  On modern hardware (dual-core AMD Opteron 2200 Sun X4100s running Solaris 10) the parse takes less than 10 seconds to run and introduces no noticeable load on the server.  My code (below) spits out a frozen perl data structure which I then ship off to a central server.

We do something similar except we tail-read the file, parse it and then
put the result into a suitable database. Tail-reading is easy enough in
Perl, including handling the case where the whole leases file is closed
and a new version is written.

There is no magic here, I'm sure similar solutions have been implemented
lots of times.

Steinar Haug, Nethelp consulting, sthaug at nethelp.no



More information about the dhcp-users mailing list