lunes, 28 de septiembre de 2009

SEARCHING FOR ERRORS IN THE ALERT.LOG FILE

SEARCHING FOR ERRORS IN THE ALERT.LOG FILE

Here’s a simple Unix Korn shell script that greps for “ORA-” and “ERROR” in the alert.log file. Before you run this shell script, you’ll have to change the setup variables at the top to match your environment. The DBS variable stores the Databases on a box. The ADIR variable stores the base directory for the database. The
DIRS variable stores the actual directories that you want to search for the Alert.log file. The MAILLIST variable

stores the email address to where the error findings will be sent.


#!/bin/ksh
export DBS="PATCH50 PATCH60"
export ADIR="/ora01/app/oracle/admin"
export DIRS="bdump udump cdump"
export MAILLIST=" uncleLarry@oracle.com "
export BOX=`uname -a | awk '{print$2}'`
export MAILX="/usr/ucb/Mail"

#-----------------------------------------------------------
for instance in $DBS
do
for directories in $DIRS
do
if [ -r $ADIR/$instance/$directories/alert*.log ]
then
grep -ic error $ADIR/$instance/$directories/alert*.log
if [ $? = 0 ]
then
$MAILX -s "Error in $instance log file" $MAILLIST <<'EOF'
Error in $instance log file on $BOX...
Check $ADIR/$instance/$directories/alert*.log
EOF
fi # $?
grep -ic ORA- $ADIR/$instance/$directories/alert*.log
if [ $? = 0 ]
then
$MAILX -s "ORA- Error in $instance log file" $MAILLIST <<'EOF'
Error in $instance log file on $BOX...
Check $ADIR/$instance/$directories/alert*.log
EOF
fi # $?
fi # -r
done # for directories
done # for instance
exit

No hay comentarios: