#!/usr/bin/ksh ############################################################################# # Server up status , ping script , and email / page if server goes down. # checks in every 10 minutes .... Coded By:- - - R A J D. - # 10,20,30,40,50,59 * * * * (/home/raj/upstat) # # Coded by : rajib22@yahoo.com Raj.D , Bangalore. India. # File Name: upstat File Type: ksh script . ############################################################################ # SCRIPT LOCATION= /home/raj/upstat # SERVERLIST FILE= servers.list EMAIL=youremail@domain.com PAGE=yourpage_no@serviceprovider.com cd /home/raj/ping DT=`date | awk '{print $2 ,$3 , substr($4,1,5)}'` DT1=`date +%Y%m%d` echo "" for i in `cat servers.list` do echo $i ping -c 3 $i | grep packet | awk '{print $7}' > abc UPSTAT=`cat abc` DOWNSTAT=100% if [ $UPSTAT = $DOWNSTAT ] then tput bold ; echo "[DOWN]" ; tput rmso # Paging Notification !! ######################################## echo "SERVER $i DOWN !!! AT $DT EST ------------ " | mailx -s "Server Down!! Status" $PAGE # Email Notification !! ######################################## echo "SERVER $i DOWN !!!! AT $DT EST " | mailx -s "* * Server Down!! Status" $EMAIL # Storing in a LOG file. ######################################### echo "SERVER $i DOWN !!!! At: $DT ----------- " >> downlog else echo "[OK]" echo " " fi done echo "-------------------- UPSTAT SCRIPT Running .. $DT " >> downlog