#!/bin/csh -f # # testnotes.sh - written by kevin p. inscoe (inscoe@iag.net) # # # define global variables # set pagelist = "pageki@cbis.com, pagecg@cbis.com" set sleeptime = 3600 # one hour set noteshost = "notes.cbis.com" set subjectline1 = "Lotus Notes mail down: call OCC" set subjectline2 = "Lotus Notes mail up: all clear " set tmp = "/tmp/testnotes.tmp" # last hour of the day (24 hour) to run set lastrun = 23 set flag = 0 top: # # now check notes... # /bin/echo "Checking Lotus Notes server via ping at `date`..." /bin/echo " " /bin/rm -f $tmp /usr/sbin/ping $noteshost 2> $tmp if ( $status == '0' ) then /bin/cat $tmp if ( $flag == '1' ) then /bin/echo "condition cleared..." $noteshost "is back up" /bin/echo "paging out all clear..." /bin/cat $tmp | /usr/ucb/mail -s "`/bin/echo $subjectline2`" $pagelist set flag = 0 goto sleep else # all is well with the world goto sleep endif else /bin/cat $tmp if ( $flag == '1' ) then /bin/echo " " $noteshost "is still down..already paged-out..." goto sleep else goto alert endif endif alert: # # we didn't go to sleep therefore notes is down..time to wake people up # if ( $flag == '0' ) then /bin/echo $noteshost "is down...paging out..." /bin/cat $tmp | /usr/ucb/mail -s "`/bin/echo $subjectline1`" $pagelist set flag = 1 endif sleep: # goto sleep /bin/echo "sleeping..." sleep $sleeptime # check to see if we are still in our window... set hour = `/usr/bin/date '+%H'` if ( $hour < $lastrun ) goto top # # our tour of duty is over..time to bail # /bin/echo "lastrun completed...exiting at `/usr/bin/date`" exit 0