37 lines
719 B
Perl
37 lines
719 B
Perl
#! /usr/bin/perl
|
|
|
|
#
|
|
# Author: Kevin C. Miller <kevinm@andrew.cmu.edu>
|
|
# http://www.andrew.cmu.edu/~kevinm/dhcp/failover.html
|
|
#
|
|
# The copyright is with the author. We (SuSE) include this script
|
|
# with his permission.
|
|
#
|
|
|
|
|
|
use strict;
|
|
|
|
my $LastLease = '';
|
|
my $savelease = 0;
|
|
my $prlease = 0;
|
|
my $LFILE = "/var/lib/dhcp/dhcpd.leases";
|
|
$LFILE = $ARGV[1] if ($ARGV[1] ne '');
|
|
|
|
open(FILE, $LFILE);
|
|
while(my $a = <FILE>) {
|
|
if ($a =~ /^lease /) {
|
|
print $LastLease if ($prlease);
|
|
$savelease = 1;
|
|
$prlease = 0;
|
|
$LastLease = $a;
|
|
}else{
|
|
$LastLease .= $a if ($savelease);
|
|
}
|
|
if ($a =~ /^\}/) {
|
|
$savelease = 0;
|
|
}
|
|
$prlease = 1 if ($a =~ /$ARGV[0]/);
|
|
}
|
|
close(FILE);
|
|
print $LastLease if ($prlease);
|