[ To find network info ]
ip link | egrep -v 'lo:|loopback' | awk \
'BEGIN { i=0; }
{if($1 ~ /^[0-9]*:/) { DEV_NAME=$2; i++ }}
i==0 { next; }
{if($1=="link/ether") { DEV_MAC=$2; i++ }}
i==2 { printf("%s %s\n", DEV_NAME, DEV_MAC); i=0 }
' | sed -e 's/: / /'
...
do
ip -4 addr | grep 'inet'
# if it is a related interface
if [ -d /proc/net/bonding ]
then
cd /proc/net/bonding; : > /tmp/dummy
DEV_ADDR=`grep -w ${DEV_NAME} * /tmp/dummy 2> /dev/null | head -1 | tr ':' ' ' | awk '$NF=="'${DEV_NAME}'" { print "(Related="$1")"; }'`
fi
...
done
;;
No comments:
Post a Comment