shell简单编程——自动ping多台主机,返回结果

说明:有时候要求每天查看某些主机是否能ping通,可通过简单脚本实现。

 

#!/bin/sh
echo "---------------------------------------"
server0="172.72.101.137/103.205"
server1="172.72.101.46"
server2="172.72.101.47"
server3="172.72.103.221"
server4="172.72.103.222"
server5="172.72.103.223"
server6="172.72.103.224"
server7="172.72.103.225"
server8="172.72.103.226"
pingcmd()
{
prefixt="SERVER $1 PING $2"
ping -w 1 -c 1 $2>/dev/null
ret=$?
if [ $ret -eq 0 ]

then printf "$prefixt OK\n"
else printf "$prefixt ERROR\n"
fi
return 0
}
"ping.sh" 35 lines, 674 characters

 

你可能感兴趣的:(linux系统类)