#!/bin/bash
HOST="google.com"
COUNT=1
#PACKET_SIZE=<to_guess>
SUBJECT="Server is down"
EMAIL_ADDR="xxx@gmail.com"
for myhost in $HOST
do
count=0
for ((i=1; i<=3; i++))
do
count=$(($count + $(ping -c $COUNT $myhost | grep received | awk -F ',' '{print $2}' | awk '{print $1}')))
#echo "$count"
done
if [ $count -eq 0 ]; then
echo "Host $myhost is down at $(date)" | mail -s "$SUBJECT" $EMAIL_ADDR
#echo "Failed"
fi
done
No comments:
Post a Comment