Net::ISC::DHCPd::Leases - Parse ISC DHCPd leases
my $leases = Net::ISC::DHCPd::Leases->new( file => '/var/lib/dhcp3/dhcpd.leases', ); # parse the leases file $leases->parse; for my $lease ($leases->leases) { say "lease has ended" if($lease->ends < time); } if(my $n = $leases->find_leases({ ends => time }) { say "$n lease(s) has expired now"; }
An object constructed from this class represents a leases file for the dhcpd server. It is read-only, so changes to the leases file must be done through a running server, using Net::ISC::DHCPd::OMAPI.
The object has one important attribute, which is "leases". This attribute holds a list of Net::ISC::DHCPd::Leases::Lease objects constructed from all the leases found in the leases file.
Holds a list of all the leases found after reading the leases file.
This attribute holds a Path::Class::File object to the leases file. It is read-write and the default value is "/var/lib/dhcp3/dhcpd.leases".
Read lines from "file", and parses every lease it can find. Returns the number of leases found. Will add each found lease to "leases".
This method will return zero or more Net::ISC::DHCPd::Leases::Lease objects as a list. It takes a hash-ref which will be matched against the attributes of the child leases.
See Net::ISC::DHCPd.
To install Net::ISC::DHCPd, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::ISC::DHCPd
CPAN shell
perl -MCPAN -e shell install Net::ISC::DHCPd
For more information on module installation, please visit the detailed CPAN module installation guide.