[ To find network info ]
ifconfig -a4 | awk \
'{if($0 ~ /^[a-z]/)
print "DEVBLOCK\n"$0;
else
print $0;
} END { print "DEVBLOCK"; }' | awk \
'BEGIN { i=0; }
{if($2 ~ /^flags/) { DEV_NAME=$1; i++ }}
i==0 { next; }
{if($2 ~ /^flags/ && $0 ~ /STANDBY/) INACT="Y"; }
{if($1=="inet") { DEV_ADDR=$2; i++ }}
{if($1=="groupname") { DEV_GRP=$2; }}
{if($1=="ether") { DEV_MAC=$2; i++ }}
{if(i==3) {
printf("%s %s %s %s %s\n", DEV_NAME, DEV_MAC, DEV_ADDR, INACT, DEV_GRP);
i=0; INACT="N"; DEV_GRP="";
}
else if($1=="DEVBLOCK" && i==2) {
printf("%s %s %s %s %s\n", DEV_NAME, "-", DEV_ADDR, INACT, DEV_GRP);
i=0; INACT="N"; DEV_GRP="";
}
}' | sed -e 's/: / /' | grep -v '^lo'
...
...
;;
No comments:
Post a Comment