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.
To parse the leases file, this module use POE::Filter::DHCPd::Lease, but this can be customized by setting _parser in the constructor. Even though it is possible, it is recommended to add features/ bugfixes to POE::Filter::DHCPd::Lease instead.
_parser
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.
This method does not make much sense, and will probably get removed. See "DESCRIPTION" for more details.
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.