搜索热词
下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
#!/bin/sh
# halt command
HALT=halt
ping_forever_host(){
IP=$1
time_out=$2
count=3
kernel=`uname -s`
total_miss=0
echo "ups check host '${IP}' for (${time_out}) seconds,[forever mode]"
# ping host,if miss recieved packets,then add to total_miss
while true
do
case $kernel in
VMkernel) #esxi 5.1
ret=`ping -c ${count} -W 1 ${IP} 2>&1|grep 'packets transmitted'|sed 's/.*,\(.*\) packets received,.*/\1/'`
;;
Darwin) #MacOS X 10.7.4
ret=`ping -c ${count} -W 1 ${IP} 2>&1|grep 'packets transmitted'|sed 's/.*,.*/\1/'`
;;
Linux) #ubuntu 12.04
ret=`ping -