监控服务器是否存活
#! /bin/bash
N=2
[email protected]
while :; do
ipfile=/usr/local/sbin/serverip.txt
for ip in `cat $ipfile`; do
mailfile=/tmp/pkgloss.txt
pkgloss=`ping -c4 $ip |grep 'transm' |awk -F',' '{print $2}' |awk '{print $1}'`
if [ $pkgloss -lt $N ]; then
echo $ip >$mailfile
ping -c4 $ip |grep 'transm' >>$mailfile
mail -s "$ip loss packets" $rmail<$mailfile
fi
done
sleep 100
done
none