#!/bin/sh # Name : /public/scripts/chkpsdm # Purpose : Monitoring which daemons are up # By : Yariv Sheizaf # Date : 12-Aug-2001 ## Define hostname and administrator login for sending email HOST=`hostname` admin=yariv@globecom-interactive.com ## Define report files CURFILE=/tmp/$$.chkpsdm.cur PREFILE=/tmp/$$.chkpsdm.pre DIFFILE=/tmp/$$.chkpsdm.dif \rm -f $DIFFILE $PREFILE $CURFILE touch $DIFFILE $PREFILE $CURFILE ## main loop while true do sleep 10 \rm -f $DIFFILE $PREFILE mv $CURFILE $PREFILE ## Create report file of running processes PROCF=/tmp/procfil$$ ps -ef -o args >$PROCF for i in Npdd Lsm http java startTrap startIsAli startWeb sdud sdad rmserver do grep $i $PROCF | awk '{print $NF}' | sort | uniq >> $CURFILE done ## Compare current Globecom services status with previous interval's status ## Send email to administrator if the status was changed during this interval diff $CURFILE $PREFILE > $DIFFILE ISDIFF=`wc -l $DIFFILE | awk '{print $1}'` if [ "$ISDIFF" != "0" ] then /usr/ucb/mail -s " Globecom services change report on - $HOST " $admin <<- EOF `diff $CURFILE $PREFILE` EOF \rm -f $DIFFILE touch $DIFFILE fi done ## Remove temporary files \rm -f $CURFILE $PREFILE $DIFFILE exit 0