#!/usr/bin/perl #Kyoma TAKAHASHI www@kyoma.org 2000.01.21 $dhcpl = '/var/dhcp/dhcpd.leases'; $dhcpc = '/etc/dhcp.client'; $dhcpo = '/var/dhcp/dhcp.unauth'; &dateget; open(OUT,">> "."$dhcpo"); open(LEASE,"< "."$dhcpl"); while() { chop($_); if (/^\s+hardware\sethernet\s/) { ($hwaddr) = /^\s+hardware\sethernet\s([0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f])/; $regist = 'no'; open(CLIENT,"< "."$dhcpc"); while() { chop($_); if ($hwaddr eq $_ ) { $regist = 'yes'; } } close(CLIENT); if ( $regist ne 'yes' ) { print OUT '['.$date.'] '.$hwaddr,"\n"; } }} close(LEASE); close(OUT); sub dateget { open(DATE,"date ".'"+%a %b/%d/%Y %H:%M %Z"'."$dateopt"." |"); $date = $_ while(); chop($date = $date); close(DATE); }