测试ip连接
[root@master ~]# cat ip.sh
#!/bin/bash
master_name=`hostname`
echo $master_name
if [[ $master_name == 'master' ]];then
echo "hostname[master] set ok!"
else
echo "hostname[master] set fail! Current hostname is $master_name"
fi
master_ip=$(ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:")
echo $master_ip
if [[ $master_ip == '192.168.200.201' ]];then
echo "master ip[192.168.200.201] set ok!"
else
echo "master ip[192.168.200.201] set fail! Current hostname is $master_ip"
fi
master_java=$(java -version 2>&1 |awk 'NR==1')
if [[ $? == 0 ]];then
echo "master $master_java set ok!"
else
echo "master $master_java set fail!"
fi
ping_out=$(ping -c 3 -w 100 www.baidu.com)
if [[ $? == 0 ]];then
echo "master ping baidu ok!"
else
echo "master ping baidu fail!"
fi
for siteip in $(seq 202 203)
do
site="192.168.200.$siteip"
echo $site
ping -c1 -W1 $site &> /dev/null
if [[ $? == 0 ]]; then
echo "ping $site ok"
else
echo "ping $site fail"
fi
done
[root@master ~]#
遗留问题
#如何测试免密登录是否成功除了
[root@master ~]# cat test.sh
#!/bin/bash
ssh root@192.168.200.202
#echo "test"
if [[ $? == 0 ]];
then
exit
echo "login ok"
else
echo "login fail"
fi
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/140776.html