NAME

Net::ISC::DHCPd::Leases - Parse ISC DHCPd leases

SYNOPSIS

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";
}

DESCRIPTION

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.

ATTRIBUTES

leases

Holds a list of all the leases found after reading the leases file.

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".

METHODS

parse

Read lines from "file", and parses every lease it can find. Returns the number of leases found. Will add each found lease to "leases".

find_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.

COPYRIGHT & LICENSE

AUTHOR

See Net::ISC::DHCPd.