#!/bin/bash
##By Leif Updated:2008-07-03 AM
# add ip / hostname separated by while space
HOSTS=”221.179.216.130 221.179.216.131 218.204.252.100 218.204.252.81 218.204.252.82 218.204.252.96 218.204.252.83 218.204.252.96 21
8.204.252.83 218.204.252.98 218.204.252.87 218.204.252.87 218.204.252.97 218.204.252.101 218.204.252.102 218.204.252.96″
# no ping request
COUNT=1
”
for myHost in $HOSTS
do
count=$(ping -c $COUNT $myHost | grep ‘received’ | awk -F’,’ ‘{ print $2 }’ | awk ‘{ print $1 }’)
if [ $count -eq 0 ]; then
# 100% failed
echo “Host : $myHost is down (ping failed) at $(date)” | email -b -s “$myHost ping is faild” $EMAILID
fi
done
exit 0
阅读(1972) | 评论(0) | 转发(0) |