how to count IPs in use

David W. Hankins dhankins at isc.org
Tue Oct 6 17:14:15 UTC 2009


On Mon, Oct 05, 2009 at 12:27:37PM +0100, Simon Hobson wrote:
> # All times in this file are in UTC (GMT), not your local timezone.   This 
> is
> # not a bug, so please don't ask about it.   There is no portable way to
> # store leases in the local timezone, so please don't request this as a
> # feature.   If this is inconvenient or confusing to you, we sincerely
> # apologize.   Seriously, though - don't ask.

This comment doesn't appear in the lease db anymore...not since we
added the db-time-format config option;

       The db‐time‐format statement

          db‐time‐format [ default | local ] ;

          The  DHCP  server  software  outputs several timestamps when writing
          leases to persistent storage.  This configuration parameter  selects
          one of two output formats.  The default format prints the day, date,
          and time in UTC, while the local format prints the  system  seconds‐
          since‐epoch,  and  helpfully provides the day and time in the system
          timezone in a comment.  The time formats are described in detail  in
          the dhcpd.leases(5) manpage.

So if you prefer to see local timestamps in dhcpd.leases, you may use
'local' setting, and it appears in a comment to the right of the date.

Note this will break any other tools that parse the information in the
old format (why we didn't make this the new default).


dhcpstatus is cool but when I'm in CLI, I often just "Control-R" and
find this in my bash history;

  awk '/^lease / { curlease = $2; } /^  binding state/ { lstates[curlease] = $3; } END { for (curl in lstates) { tstates[lstates[curl]]++; } for (curs in tstates) { print curs, tstates[curs]; } }' /var/db/dhcpd.leases

It prints output like;

  active; 48
  free; 81
  backup; 158

Which is useful to me as a spot-check.

-- 
David W. Hankins	"If you don't do it right the first time,
Software Engineer		     you'll just have to do it again."
Internet Systems Consortium, Inc.		-- Jack T. Hankins
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20091006/ce299d4e/attachment.bin>


More information about the dhcp-users mailing list