Static Lease Logging

Frank Sweetser fs at WPI.EDU
Thu Nov 27 13:49:57 UTC 2008


ben.tanner at canterbury.ac.uk wrote:
> Apologies if this has already been covered, but a brief google hasn't
> turned up anything yet.
> 
> We're currently running a 'tweaked' version of dhcpd 3.0.3 that logs static
> leases out to the dhcpd.leases file along with the dynamics. We currently
> monitor dhcpd.leases with gamin/FAM, and then we scrape the leases out of
> the file and squirt them into a SQL database, where they are de-duplicated
> and recorded against our asset/IPAM database, so we can see the last time a
> static address was issued etc.
> 
> I'd really like to upgrade dhcpd since it's about 3 years out of date and
> there have been a number of fixes for a few bugs that we're seeing with
> areas like failover. Additionally I'd like to switch to using a standard
> RHEL rpm rather than the proprietary version we currently run, for
> maintainability's sake. Unfortunately the staff member that made the
> modifications to the code has long since left, and I'm no coder myself, so
> I'm curious if anyone else has found a more elegant way of recording static
> leases being issued?

We gather up that data by using the on commit statement to generate a log
message, and pull the data out of syslog rather than the lease file itself.

on commit { if (static) {
              log (info, concat (
                "DHCPNETMON ",
                binary-to-ascii (10,32,"",encode-int (lease-time,32))," ",
                substring (binary-to-ascii (16,8,":",hardware), 2,17)," ",
                binary-to-ascii (10,8,".",leased-address)," ",
                pick-first-value(host-decl-name, "(none)"),
                " static"));
            } else {
              log (info, concat (
                "DHCPNETMON ",
                binary-to-ascii (10,32,"",encode-int (lease-time,32))," ",
                substring (binary-to-ascii (16,8,":",hardware), 2,17)," ",
                binary-to-ascii (10,8,".",leased-address), " ",
                pick-first-value(ddns-fwd-name, "(none)"),
                " dynamic"));
            }
}

-- 
Frank Sweetser fs at wpi.edu  |  For every problem, there is a solution that
WPI Senior Network Engineer   |  is simple, elegant, and wrong. - HL Mencken
    GPG fingerprint = 6174 1257 129E 0D21 D8D4  E8A3 8E39 29E3 E2E8 8CEC



More information about the dhcp-users mailing list