Free IPs on dhcp

Hi,

could someone help me get an option to get the amount of free IPs on an ip pool?
i would like to use it for a skript that warns me if im almost running out of ips,

for example write a mail if there are less then X ips free