how to count IPs in use
Peter Laws
plaws at ou.edu
Wed Oct 7 13:39:44 UTC 2009
David W. Hankins wrote:
> 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.
Very nice! One of my servers serves many networks and I'm really only
concerned about one of them. Adding the first three octets of the IP
address to "^lease " didn't seem to do the trick ... pointers?
Other than to the O'Reilly sed and awk book, I mean. :-)
--
Peter Laws / N5UWY
National Weather Center / Network Operations Center
University of Oklahoma Information Technology
plaws at ou.edu
-----------------------------------------------------------------------
Feedback? Contact my director, Craig Cochell, craigc at ou.edu. Thank you!
More information about the dhcp-users
mailing list