#!/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
#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