return to PRS Technologies website
################################################################################
#!/usr/bin/ksh
################################################################################
#
# Module: check_db_access.sh
# Author: Peter R. Schmidt
# Description: Check and log access to the database
# Make 4 attempts per minute - each 15 seconds apart
#
# Arguments
#
# Argment: -v Interactive - display to screen - no e-mail
#
# Change Log
#
# Date Name Description.................
# 09/03/02 Peter R. Schmidt Start Program
#
################################################################################
FG=false
for ARG
do
case "$ARG" in
-v) FG=true;;
esac
done
# Set the environment
. /elite/custom/run.elite
LOGDIR=/elite/work/logs
LOGFILE=$LOGDIR/check_db_access.log
TMPFILE=/tmp/check_db_access.log
rm -f $TMPFILE
if [ ! -d $LOGDIR ]; then
echo "Error: check_db_access.sh: Directory: $LOGDIR does not exist!"
exit 1
fi
#-------------------------------------------------------------------------------
for TRY in 1 2 3 4 # Make 4 attempts per minute - seach 15 seconds apart
do
UDATE=`date +%m/%d/%y`
UTIME=`date +%H:%M:%S`
# Try to access the database - log failures
dbaccess son_db <<-EOF 2>&1 > $TMPFILE
EOF
if [ $? != 0 ]; then
echo "$UDATE $UTIME Fail" >> $LOGFILE
cat $TMPFILE >> $LOGFILE
if [ $FG = true ]; then
tail -1 $LOGFILE
cat $TMPFILE
fi
else
echo "$UDATE $UTIME OK" >> $LOGFILE
fi
if [ $FG = true ]; then
break
else
sleep 15 # Make 4 attempts per minute - seach 15 seconds apart
fi
done
rm -f $TMPFILE
################################################################################