bond-check脚本

#!/bin/bash
Bond=/proc/net/bonding/bond0
if [ -f $Bond ];then
Net1=`cat /proc/net/bonding/bond0 |grep “Slave Interface”|head -1|awk ‘{print $3}’`
Net2=`cat /proc/net/bonding/bond0 |grep “Slave Interface”|tail -1|awk ‘{print $3}’`
Speed1=`cat /proc/net/bonding/bond0 |grep Speed|awk ‘{print $2}’|head -1`
Speed2=`cat /proc/net/bonding/bond0 |grep Speed|awk ‘{print $2}’|tail -1`
if [ “$Speed1” = “Unknown” ];then
Speed1=0
a1=Unknown
elif [ “$Speed2” = “Unknown” ];then
Speed2=0
a2=Unknown
fi
if [ $Speed1 ];then
if [ $Speed1 -eq 1000 -a $Speed2 -eq 1000 ];then
echo “Bond is ok!”
elif [ $Speed1 -eq 1000 ];then
if [ $Speed2 -lt 1 ];then
echo “$Net2 is ${a2} !!!”
else
echo “$Net2 is $Speed2 M/s!!!”
fi
elif [ $Speed2 -eq 1000 ];then
if [ $Speed1 -lt 1 ];then
echo “$Net1 is $a1 !!!”
else
echo “$Net1 is $Speed1 M/s!!!”
fi
else
if [ $Speed1 -eq 0 ];then
echo “$Net1 is $a1 !!!”
else
echo “$Net1 is $Speed1 M/s!!!”
fi
if [ $Speed2 -eq 0 ];then
echo “$Net2 is $a2 !!!”
else
echo “$Net2 is $Speed2 M/s!!!”
fi
fi
else
Speed1=`ethtool $Net1|grep Speed|awk ‘{print $2}’|awk -FM ‘{print $1}’`
Speed2=`ethtool $Net2|grep Speed|awk ‘{print $2}’|awk -FM ‘{print $1}’`
if [ “$Speed1” = “Unknown!” ];then
Speed1=0
a1=Unknown

elif [ “$Speed2” = “Unknown!” ];then
Speed2=0
a2=Unknown
fi
if [ $Speed1 -eq 1000 -a $Speed2 -eq 1000 ];then
echo “Bond is ok!”
elif [ $Speed1 -eq 1000 ];then
if [ $Speed2 -lt 1 ];then
echo “$Net2 is $a2 !!!”
else
echo “$Net2 is $Speed2 M/s!!!”
fi
elif [ $Speed2 -eq 1000 ];then
if [ $Speed1 -lt 1 ];then
echo “$Net1 is $a1 !!!”
else
echo “$Net1 is $Speed1 M/s!!!”
fi
else
if [ $Speed1 -eq 0 ];then
echo “$Net1 is $a1 !!!”
else
echo “$Net1 is $Speed1 M/s!!!”
fi
if [ $Speed2 -eq 0 ];then
echo “$Net2 is $a2 !!!”
else
echo “$Net2 is $Speed2 M/s!!!”
fi
fi
fi
else
echo “The machine no Bond!!!”
fi

原创文章,作者:赛福,如若转载,请注明出处:https://www.safecdn.cn/241.html

本站不销售、不代购、不提供任何支持,仅分享网络信息,请自行辨别,请遵纪守法、文明上网。