119 ~/M2/image-installer-bak$ 脚本
sdcm@sdcm:~$ cat ping.sh1
#!/bin/bash
IP=(
172.16.0.200
172.16.0.201
172.16.0.202
172.16.0.203
172.16.0.204
172.16.0.205
172.16.0.210
172.16.0.211
172.16.0.212
172.16.0.213
172.16.0.214
172.16.0.215
172.16.0.216
172.16.0.217
)
echo "Start ping at : "`date +%Y-%m-%d-%H:%M:%S`
for PING in ${IP[*]} ;do
CHECK=`ping -c 1 -w 1 $PING |grep "time="|awk ‘{print $4}‘`
if [ "$CHECK" = "" ];then
echo ${PING}"---""OFFLINE..."`date +%Y-%m-%d-%H:%M:%S`
else
echo ${PING}"---""OK---OK..."`date +%Y-%m-%d-%H:%M:%S`
fi
done
echo "Finished ping at : "`date +%Y-%m-%d-%H:%M:%S`
sdcm@sdcm:~$ ./ping.sh1
Start ping at : 2014-10-30-11:53:03
172.16.0.200---OK---OK...2014-10-30-11:53:03
172.16.0.201---OK---OK...2014-10-30-11:53:03
172.16.0.202---OK---OK...2014-10-30-11:53:03
172.16.0.203---OK---OK...2014-10-30-11:53:03
172.16.0.204---OK---OK...2014-10-30-11:53:03
172.16.0.205---OK---OK...2014-10-30-11:53:03
172.16.0.210---OK---OK...2014-10-30-11:53:03
172.16.0.211---OK---OK...2014-10-30-11:53:03
172.16.0.212---OK---OK...2014-10-30-11:53:03
172.16.0.213---OK---OK...2014-10-30-11:53:03
172.16.0.214---OK---OK...2014-10-30-11:53:03
172.16.0.215---OK---OK...2014-10-30-11:53:03
172.16.0.216---OK---OK...2014-10-30-11:53:03
172.16.0.217---OK---OK...2014-10-30-11:53:03
Finished ping at : 2014-10-30-11:53:03
sdcm@sdcm:~$ ping -c 1 -w 1 172.16.0.200
PING 172.16.0.200 (172.16.0.200) 56(84) bytes of data.
64 bytes from 172.16.0.200: icmp_req=1 ttl=64 time=0.835 ms
--- 172.16.0.200 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.835/0.835/0.835/0.000 ms
sdcm@sdcm:~$ ping -c 1 -w 1 172.16.0.200 |grep time\=
64 bytes from 172.16.0.200: icmp_req=1 ttl=64 time=0.839 ms
arp -an -i br0 |grep -v incom |grep -v 172.16.0. |awk -F "(" ‘{print $2}‘|awk -F ")" ‘{print $1}‘|sort
4、
原文:http://www.cnblogs.com/hanxing/p/4095490.html