批量ping和ssh测试一批服务器ip是否可以连通"/>
shell脚本批量ping和ssh测试一批服务器ip是否可以连通
1、ping脚本
# cat ping.sh
#!/bin/bash
for ip in `cat list`;
doif ping -c1 -w1 ${ip} &>/dev/null;thenecho "${ip}:yes ping"elseecho "${ip}:no ping"fi
done
2、list文件存放服务器ip
# cat list
10.186.186.101
10.186.186.1023、执行ping.sh脚本,测试list文件ip列表是否可以ping通
# sh ping.sh
10.186.186.101:yes ping
10.186.186.102:no ping
1、ssh脚本
# cat ssh.sh
#!/bin/bash
for i in `cat list` ; dossh -o ConnectTimeout=3 $i >/dev/null 2>&1if [ $? -eq 0 ];thenecho "$i:yes ssh";exitelseecho "$i:no ssh"fi
done
更多推荐
shell脚本批量ping和ssh测试一批服务器ip是否可以连通
发布评论