#!/bin/csh -f ####################################################################### # # OnDemand System Log Tool # ####################################################################### # written by Kevin P. Inscoe (kevin@inscoe.org) # http://www.inscoe.org/ondemand # August 26, 1999 # Fetches the OnDemand System Log into unix ascii file # Global Variables set host = `/bin/hostname` set logfile = "/var/log/ars_system.log" set ADMIN = "admin" set PASSWORD = "jazman11" set tmp = "/tmp/ars_system.tmp" set seedfile = "/opt/monitor/arssys_seedfile.dat" set sleeptime = 600 # 10 minutes # last hour of the day (24 hour) to run @ lasthour = 23 # Annouce ourselves /bin/echo "+++++++++++++++++++++++++++++++++++++++++++" /bin/echo $0 "Starting at `/usr/bin/date`" # cleanup from last time if ( -e $tmp ) /bin/rm -f $tmp # First see if our seed file exists. If it doesnt seed it set seeddate = `/bin/date +"%m/%d/%C%y:%H:%M:%S"` if ( ! -e $seedfile ) then /bin/echo "seedfile `/bin/echo $seedfile` not found. creating initial seedfile. seeddate:" $seeddate /usr/lpp/ars/bin/arsdate -f %m/%d/%Y:%H:%M:%S -z "`/bin/echo $seeddate`" | /bin/awk '{ print $3 }' > $seedfile /bin/chmod 500 $seedfile endif top: # # Generate new seed - IMPORTANT that this step remain AHEAD of # arsquery so we do not lose any records that get logged between now # and when arsquery runs. Of course we run a slight risk of record # duplication in our resulting log output - but duplication is better # then loss! # set seeddate = `/bin/date +"%m/%d/%C%y:%H:%M:%S"` /bin/date /bin/echo "new seeddate:" $seeddate # Using query method /usr/lpp/ars/bin/arsquery -h $host -u $ADMIN -p $PASSWORD -v -o $tmp -f "System Log" -i "where time_stamp > `/bin/cat $seedfile`" /bin/cat $tmp >> $logfile /usr/bin/chmod 755 $logfile # cleanup.. if ( -f $tmp ) /bin/rm -f $tmp # Repopulate seedfile /bin/chmod 700 $seedfile /usr/lpp/ars/bin/arsdate -f %m/%d/%Y:%H:%M:%S -z "`/bin/echo $seeddate`" | /bin/awk '{ print $3 }' > $seedfile /bin/chmod 500 $seedfile /bin/echo "new seed internal date: `/bin/cat $seedfile`" loop_check: # check to see if we are still in our window... @ hour = `/usr/bin/date '+%H' | /bin/awk '{ printf("%d\n", $1) }'` if ( $hour == $lasthour ) goto bail # goto sleep /bin/echo "sleeping..." sleep $sleeptime goto top bail: # # our tour of duty is over..time to bail # /bin/echo $0 "hour=" $hour "lastrun completed...exiting at `/usr/bin/date`" exit 0