- #!/bin/sh
- seralive(){
- ttlget=`ping -c 1 $desip |grep -v "PING" |grep "ttl" |awk '{print $6}'|awk -F '=' '{print $1}'`
- if [ "$ttlget" == "ttl" ]
- then
- echo -e "$desip 连接正常\n"
- else
- for ((i=1; i<5;i++))
- do
- echo -ne "\r$desip尝试第$i次连接..."
- sleep 0.2
- ttlget1=`ping -c 1 $desip |grep -v "PING"| grep "ttl" |awk '{print $6}'|awk -F '=' '{print $1}'`
- if [ "$ttlget1" == "ttl" ]
- then
- echo -ne "连接正常"
- break
- else
- echo -ne "连接异常"
- fi
- done
- echo -e "\n"
- fi
- }
- cat /root/scripts/svrsip |while read desip
- do
- seralive
- sleep 0.2
- done
以上是脚本部分内容,下面是服务器列表文件svrsip的内容:
192.168.0.1
192.168.0.2
192.168.0.3
.....
在缺乏CACTI、NAGIOS、ZENOSS等专业运维监控软件时,临时可以用下这个短小的脚本来排除故障.
阅读(1943) | 评论(0) | 转发(0) |