Jan Henning Thorsen > Net-ISC-DHCPd-0.14 > Net::ISC::DHCPd::Leases

Download:
Net-ISC-DHCPd-0.14.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

New  1
Open  1
View/Report Bugs
Source   Latest Release: Net-ISC-DHCPd-0.1704

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.

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.

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.

add_lease

This method does not make much sense, and will probably get removed. See "DESCRIPTION" for more details.

COPYRIGHT & LICENSE ^

AUTHOR ^

See Net::ISC::DHCPd.

syntax highlighting: