#!/bin/bash
#Scrit to check the link status.
#Date
date=`date |awk {'print $3"-"$2"-"$6"-"$4'}`
REPORT="/home/yourhome/network/report/report.log"
SUBJECT="Ping request fails on $date."
EMAILID="yourname@yourdomain.com"
EMAILFILE="/home/yourhome/network/email/email_file"
HOST="172.222.165.1"
#Ping to gateway.
COUNT=`ping -c 9 $HOST -w 10 |grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }'`
if [ $COUNT -gt 6 ]
then
echo "Link is up" >> /dev/null
exit 0
else
echo "Ping request failed on $date IST" >> $REPORT | mail -s "$SUBJECT" $EMAILID < $EMAILFILE
exit 1
fi
echo $?
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.