[ To find network info ]
case `uname -s` in
AIX)
lsdev -Cc adapter | grep '^ent' | grep Available | awk '{ print $1 }' | while read DEV_NAME
do
DEV_MAC=`lscfg -vpl ${DEV_NAME} | grep 'Network Address' | sed -e 's/[.]*[.]/ /' | awk '{ print $NF }' | awk \
'{for(i=1;i<12;i=i+2) {
m=substr($1,i,2);
MAC=MAC":"m;
}
print MAC;
}' | sed -e 's/^://'`
DEV_NAME=`echo ${DEV_NAME} | sed -e 's/ent/en/'`
# if EtherChannel (Link Aggregation)
test -z "${DEV_MAC}" && { DEV_MAC=`netstat -ni | grep link | awk '$1=="'${DEV_NAME}'" { print $4 }'`; }
DEV_ADDR=`ifconfig ${DEV_NAME} | awk '$1=="inet" { print $2}' | head -1`
...
printf "%s %s %s\n" "${DEV_NAME}" "${DEV_MAC}" "${DEV_ADDR}"
done
;;
*)
echo "This script must be run on AIX/HP-UX/SunOS/Linux."
exit 1
;;
esac
No comments:
Post a Comment