#!/bin/bash
echo $1
awk 'BEGIN{
while( (getline line < "maclist") > 0){
mac[line]
}
RS="}"
FS="\n"
}
/lease/{
for(i=1;i<=NF;i++){
gsub(";","",$i)
hostname=""
if ($i ~ /lease/) {
m=split($i, IP," ")
ip=IP[2]
}
if( $i ~ /hardware/ ){
m=split($i, hw," ")
ether=hw[3]
}
if ( $i ~ /client-hostname/){
m=split($i,ch, " ")
hostname=ch[2]
}
if ( $i ~ /uid/){
m=split($i,ui, " ")
uid=ui[2]
}
if ( $i ~ /starts/){
m=split($i,starts, " ")
st_d=starts[3]
st_t=starts[4]
}
if ( $i ~ /ends/){
m=split($i,ends, " ")
ed_d=ends[3]
ed_t=ends[4]
}
}
}
}
{
print st_d " " st_t " - " ed_d " " ed_t " ip: " sprintf("%-12s",ip)" ether: "ether " hostname: "hostname " "
}
if ( ether in mac ){
print "ip: "ip " hostname: "hostname " ether: "ether " uid: "uid
}
} ' $1
~
~
~
阅读(685) | 评论(0) | 转发(0) |