shell 监控局域网的主机是否up
#!/bin/bash for ((i=30;i<60;i++)) ;do ping -c 3 172.31.0.$i>/dev/null #ping -c 172.31.0.30 ~172.31.0.59 if [[ $? -eq 0 ]] #if up $?==0 then echo "172.31.0.$i is alive" else echo "172.31.0.$i isn't up" fi done
监控局域网的主机是否up,可以使用ping命令,如果ping 通$?等于0,ping不通 返回非0
转载请注明出处:http://www.cnblogs.com/tobecrazy/