How to query for available / used ip
Dmitry Vayntrub
dmitry at sfsu.edu
Sat Jun 20 16:23:07 UTC 2015
You might also look at dhcpd-pools
http://dhcpd-pools.sourceforge.net/
It is really fast (written in C ), and the output is easy to parse, as well as present as a web page if you would like to.
Here is an example of the text mode output:
[root at ns1 dhcp]# dhcpd-pools
Ranges:
shared net name first ip last ip max cur percent touch t+c t+c perc bu bu perc
sfs-wifi-dhcp-10_143_010.143.0.16 - 10.143.15.254 4079 16 0.392 860 876 21.476 2037 49.939
sfs-wifi-dhcp-10_143_1610.143.16.16 - 10.143.31.254 4079 17 0.417 934 951 23.315 2034 49.865
sfs-wifi-dhcp-10_143_3210.143.32.16 - 10.143.47.254 4079 18 0.441 830 848 20.789 2033 49.841
sfs-wifi-dhcp-10_143_4810.143.48.16 - 10.143.63.254 4079 21 0.515 934 955 23.413 2034 49.865
sfs-wifi-dhcp-10_143_6410.143.64.16 - 10.143.79.254 4079 27 0.662 876 903 22.138 2031 49.792
sfs-wifi-dhcp-10_143_8010.143.80.16 - 10.143.95.254 4079 17 0.417 906 923 22.628 2038 49.963
sfs-wifi-dhcp-10_143_9610.143.96.16 - 10.143.111.254 4079 17 0.417 922 939 23.020 2037 49.939
sfs-wifi-dhcp-10_143_11210.143.112.16 - 10.143.127.254 4079 17 0.417 922 939 23.020 1578 38.686
sfs-wifi-dhcp-10_143_12810.143.128.16 - 10.143.143.254 4079 17 0.417 923 940 23.045 0 0.000
sfs-wifi-dhcp-10_143_14410.143.144.16 - 10.143.159.254 4079 22 0.539 944 966 23.682 0 0.000
sfs-wifi-dhcp-10_143_16010.143.160.16 - 10.143.175.254 4079 19 0.466 910 929 22.775 0 0.000
sfs-wifi-dhcp-10_143_17610.143.176.16 - 10.143.191.254 4079 23 0.564 930 953 23.364 0 0.000
sfs-wifi-dhcp-10_143_19210.143.192.16 - 10.143.207.254 4079 20 0.490 888 908 22.260 0 0.000
sfs-wifi-dhcp-10_143_20810.143.208.16 - 10.143.223.254 4079 16 0.392 883 899 22.040 0 0.000
sfs-wifi-dhcp-10_143_22410.143.224.16 - 10.143.239.254 4079 18 0.441 1085 1103 27.041 0 0.000
sfs-wifi-dhcp-10_143_24010.143.240.16 - 10.143.255.254 4079 18 0.441 882 900 22.064 0 0.000
Shared networks:
name max cur percent touch t+c t+c perc bu bu perc
sfs-wifi-dhcp-10_143_0 4079 16 0.392 860 876 21.476 2037 49.939
sfs-wifi-dhcp-10_143_16 4079 17 0.417 934 951 23.315 2034 49.865
sfs-wifi-dhcp-10_143_32 4079 18 0.441 830 848 20.789 2033 49.841
sfs-wifi-dhcp-10_143_48 4079 21 0.515 934 955 23.413 2034 49.865
sfs-wifi-dhcp-10_143_64 4079 27 0.662 876 903 22.138 2031 49.792
sfs-wifi-dhcp-10_143_80 4079 17 0.417 906 923 22.628 2038 49.963
sfs-wifi-dhcp-10_143_96 4079 17 0.417 922 939 23.020 2037 49.939
sfs-wifi-dhcp-10_143_112 4079 17 0.417 922 939 23.020 1578 38.686
sfs-wifi-dhcp-10_143_128 4079 17 0.417 923 940 23.045 0 0.000
sfs-wifi-dhcp-10_143_144 4079 22 0.539 944 966 23.682 0 0.000
sfs-wifi-dhcp-10_143_160 4079 19 0.466 910 929 22.775 0 0.000
sfs-wifi-dhcp-10_143_176 4079 23 0.564 930 953 23.364 0 0.000
sfs-wifi-dhcp-10_143_192 4079 20 0.490 888 908 22.260 0 0.000
sfs-wifi-dhcp-10_143_208 4079 16 0.392 883 899 22.040 0 0.000
sfs-wifi-dhcp-10_143_224 4079 18 0.441 1085 1103 27.041 0 0.000
sfs-wifi-dhcp-10_143_240 4079 18 0.441 882 900 22.064 0 0.000
[root at ns1 dhcp]# dhcpd-pools -help
Usage: dhcpd-pools [OPTIONS]
This is ISC dhcpd pools usage analyzer.
-c --config file path to the dhcpd.conf file
-l --leases file path to the dhcpd.leases file
-f --format [thc] output format
t for text
h for html table
H for full html page
c for comma separated values
-s --sort [nimcptTe] sort ranges by
n name
i IP
m maxium
c current
p percent
t touched
T t+c
e t+c perc
-r --reverse reverse order sort
-o --output file output into a file
-L --limit nr output limit mask 77 - 00
-v --version version information
-h --help this screen
Report bugs to <kerolasa at iki.fi>
Thanks,
Dmitry Vayntrub
Systems Coordinator
Information Technology Services
San Francisco State University
(415)338-1909
-----Original Message-----
From: dhcp-users-bounces at lists.isc.org [mailto:dhcp-users-bounces at lists.isc.org] On Behalf Of Simon Hobson
Sent: Saturday, June 20, 2015 5:07 AM
To: Users of ISC DHCP
Subject: Re: How to query for available / used ip
Leandro <ingrogger at gmail.com> wrote:
> Hello Guys , I would like to plot the function of my dhcpd server on cacti graph.
> I want to know ir is there any recommended way to ask a running dhcp server how many ips were granted and how many are available ?
Check out dhcp-pool
As well as a command line tool, it has a munin plugin component. In principle it shouldn't be too hard to get it to update an RRD but I haven't got that far yet. As a command line tool it will give you information like this :
Subnet 192.168.7.0/24
--------------------------------------------------
1. Pool "WiFi":
Monitoring: ON
Warning limit: 75%
Critical limit: 90%
Active leases: 22/91 (24.2%)
While the Munin plugin will give you output like this :
$ dhcpd-munin_192.168.7.0_24_1
active.value 22
warning.value 68.2
critical.value 81.9
max.value 91
I figure the latter should be parseable into something that can be fed into Nagios and Cacti
_______________________________________________
dhcp-users mailing list
dhcp-users at lists.isc.org
https://lists.isc.org/mailman/listinfo/dhcp-users
More information about the dhcp-users
mailing list