#!/usr/bin/ksh # # # File: Monitor.ksh # # Description: Monitor jobs. # # Usage Info: Supplies a container to store functions # that could run every pollingInterval # # $Header$ # # $Revision$ # # Audit Trail $Log$ # 04/16/2002 Jeff Martin Initial creation. # 04/16/2002 Jeff Martin Added FS threshold checking. # ######################################################### pollingInterval=60 #seconds between monitor samples FSThreshold=85 #enableFSCritical if FS full enableFSCritical=0 #send an alarm if 1 #monitor this FS MONITORFS=/home #send alarms to these reciepients MAIL_LIST=" " #paths REPORTPATH=/home/srjobs/Rpts LOG_FILE=$REPORTPATH/Log/`basename $0`_`date "+%Y%m%d"` ################# functions ################################ checkFSThreshold () { #get detail line from bdf (ignore header) let LINE=1 bdf $MONITORFS | while read -r FS KBYTES USED AVAIL PERCENT MOUNTED do if [[ $LINE = 2 ]] ; then #only alarm when FSThreshold initially breached if [[ $PERCENT > $FSThreshold ]] ; then if [[ $enableFSCritical = 0 ]] ; then #disable FSThreshold alarms enableFSCritical=1 #send a FS full alarm echo "$MONITORFS at $PERCENT\non `hostname` at `date`" echo "$MONITORFS at $PERCENT\non `hostname` at `date`" | \ elm -s "$MONITORFS at $PERCENT" $MAIL_LIST fi else #enable FSThreshold alarms enableFSCritical=0 fi fi #LINE = 2 let LINE=LINE+1 done #read bdf } ################# main ########################################## #check to see if the script is already running BASENAME=`basename $0` ISRUNNING=`ps -ef|grep $BASENAME|grep -v vi|grep -v grep|wc -l` if [ "$ISRUNNING" -ge 2 ] then echo "\n$BASENAME already running.\n" exit 0 fi #call monitor functions every pollingInterval seconds let FOREVER=1 while [[ $FOREVER > 0 ]] ; do #check FS checkFSThreshold sleep $pollingInterval done #FOREVER ######################################################## exit 0 ########################################################