#!/bin/sh # @(#) logmon.startup - Revision 1.5 - 12/15/97 # # Start the logmon daemon. # # ============================================================================= # Andrea Whitlock, Mobius Software Services # whitlock@mobius-soft.com # # Bug reports, questions, and suggestions should be emailed to: # mobius@mobius-soft.com # # This software is provided under the terms of the GNU copyleft # (ftp://prep.ai.mit.edu/pub/gnu/COPYING-2.0), without a warranty # of any kind. Use at your own risk. # ============================================================================= # # # configure me ################################################################ # # part 1 # # set the path to logmon LOGMON=/home/logmon/bin/logmon # # part 2 # # set the path to the message log MESSAGELOG=/usr/local/etc/message.log # # part 3 # # set the path to the logmon server log LOGMONLOG=/home/logmon/log/logmon.log # # part 4 # # set the logmon server port PORT=3003 # # part 5 # # set the path to the tac command. the tac command will cat a file backwards. # it is part of the GNU text utilties (ftp://prep.ai.mit.edu/pub/gnu/textutils*) TAC=/usr/local/bin/gtac # # part 6 # # ps needs to report process status on the specifide pid PS="ps -p" # # part 7 # # if flag is set, you will get mail whenever logmon is started. useful if # this script is scheduled in cron to kick every so often (to restart logmon # if it ever dies) sendmail="yes" mailinglist="andrea" # # configure me end ############################################################ umask 000 startlog=`dirname $LOGMONLOG`/`basename $0`.log if [ ! -f $MESSAGELOG ] then touch $MESSAGELOG fi pid=`$TAC $LOGMONLOG | grep pid | head -1 | awk '{ print $NF }'` if [ "$pid" ] then process=`$PS $pid | tail +2 | awk '{ print $NF }'` fi if [ "$process" != "logmon" ] then $LOGMON $PORT $LOGMONLOG $MESSAGELOG > $startlog 2>&1 mailme="yes" else echo "Process $pid already running:\n$process" > $startlog 2>&1 fi wait if [ "$mailme" -a "$sendmail" ] then mailx -s "`basename $0`" $mailinglist < $startlog fi