监控集群的状态

来源:互联网 发布:2016淘宝店好做吗 编辑:程序博客网 时间:2024/05/21 02:50
#!/bin/sh
#node_stat.sh
rm -rf t1.txt
node_num=`sed '/^$/d' /etc/hosts|wc -l`
for node in `cat /etc/hosts|awk '(NR>=3&&NR<=7){print $2}'`
do
#       echo "node="$node
        ping -c 1 $node &> /dev/null
        if [ $? = 0 ];then
                echo "$node is up" &> /dev/null
        else
                sleep 1
                ping -c 1  $node &> /dev/null
                if [ $? = 0 ];then
                        echo "$node is up"  &> /dev/null
                else
                        #touch t1.txt
                        echo "$node is down\n" >> t1.txt
                fi
        fi
done
str=`cat t1.txt`
#echo $str"\n"
echo $str|mail -s 'cluster network stat' mpi@mpi.com
exit 0
0 0
原创粉丝点击