网络质量批量检测脚本

1466阅读 0评论2012-06-17 initrdimg
分类:Python/Ruby

#!/bin/bash
#luohongjiang
#qq:123769752
#netchk v 1.3
. InfoData
_ping_no=${1-1}
_ping_size=${1-1}

echo "Net status check..."
for i in $IP
{
ping -c $_ping_no -s $_ping_size $i >ping.log
cat ping.log|grep "time="|tail -n 1
cat ping.log|grep "$_ping_no received"
if (( $? >0 ));then
cat ping.log|grep "received"
echo -e $ys_red "****************$i Have question" $ys_o
else
echo -e $ys_green "****************$i is ok" $ys_o
fi
}
rm ping.log

echo "Net Interface check"
for i in $IP
{  
  
  _in_no=$(ssh  root@$i cat /proc/net/dev|awk '{print $1}'|grep ":[0-9]"|awk -F '[:]' '{print $1}')
  for ck in $_in_no
  {
   ssh  root@$i "ifconfig $ck"|grep "$i" >/dev/null
   if (( $? == 0 ));then
         ssh root@$i "ethtool $ck"|grep -E "Speed|Duplex"
ok_ck=$ck
fi
  } 
  echo "***********************************$i [$ok_ck]"
}

上一篇:程序更新脚本备份
下一篇:syslog 详细解释及编程接口