Net::DHCP::Watch - A class for monitoring a remote DHCPD server. |
Net::DHCP::Watch - A class for monitoring a remote DHCPD server.
use Net::DHCP::Watch; # server name my $Server = 'dhcpd.mydomain.com'; # this machine ip and ethernet address my $IP = '192.168.1.1'; my $Ether = '01:23:45:67:89:ab'; # Net::DHCP::Watch object my $dhcpw = new Net::DHCP::Watch({ server => $Server, client => $IP, ether => $Ether });
# Open network $dhcpw->watch(); # Get status my $stat = $dhcpw->status; # print results if ( $stat->{Bad} ) print $stat->{Time}, ": Remote DHCP on $Server unavailable (",$stat->{Bad},").\n";
if ( $stat->{Ok} ) print $stat->{Time}, ": Remote DHCP on $Server online.\n";
Net::DHCP::Watch is a module to help monitor remote DHCP servers. It opens an udp socket to send and receive responses to and from a DHCP server. It stores the last connection status information.
This module serves to implement This module can help to write some simple code to implement a reliable DHCP service over complex or simple networks.
my $ether = qx[ /sbin/ifconfig eth0 | tail +1 |\ head -1 | awk '{print \$5}']; chomp($ether);
See the directory examples in source distribution for an example.
There should be a Net::DHCP class to handle the DHCP protocol.
On platforms without alarm() function defined the monitoring can hang forever if some network problems show up (cable problem, etc)?
The machine that is running the test MUST BE a KNOWN client of the remote DHCP server.
Evilio del Rio, edelrio@icm.csic.es
I would like to acknowledge the valuable contributions of the people who made suggestions to improve this code, specially to Nick Garfield who provided the solution for monitoring disjoint networks.
perl(1), the IO::Socket(3) manpage, the Net::hostent(3) manpage. RFCs 2131 and 2132.
Ralph Droms & Ted Lemon, The DHCP Handbook, MacMillan (Indianapolis), 1999.
Net::DHCP::Watch - A class for monitoring a remote DHCPD server. |