#############################################
#!/bin/ksh
set -x
# File: chk_alrtlog.sh
# Last updated: 12/18/2008
# Purpose: Check for Alert log errors
#############################################
ORACLE_SID=$1; export ORACLE_SID
DB=$2; export DB
ADMINDR=$ORACLE_BASE/admin/$DB
BDUMP=$ADMINDR/bdump
CFGDIR=$HOME/cron/cfg
ALRTLOG=$BDUMP/alert_${ORACLE_SID}.log
TMPALRTLOG=/tmp/alrtlog_err.log
ERRORFILE1=/tmp/alrtlog_err1.log
ERRORFILE2=/tmp/alrtlog_err2.log
DBAMAIL=email@domain.com
DBAPAGER=pager@domain.com
tail -20 $ALRTLOG > $TMPALRTLOG
cat $TMPALRTLOG | while read LINE
do
ERROR="$(echo $LINE | grep -hie 'ORA-' -ihe 'error' -ihe 'warn' -ihe 'deadlock')"
if [[ -n $ERROR ]] ; then
echo $ERROR >> $ERRORFILE1
fi
done
#NEWERRORS="$(diff $ERRORFILE1 $ERRORFILE2)"
#if [[ -n $NEWERRORS ]] ; then
#if [ `ls -l $ERRORFILE1|awk '{print $5}'` -ge 0 ];then
NEWERRORS=`wc -l $ERRORFILE1 | awk -F" " '{print $1}'`
OLDERRORS=`wc -l $ERRORFILE2 | awk -F" " '{print $1}'`
if [[ $NEWERRORS -ne $OLDERRORS ]] ; then
if [[ $NEWERRORS -gt 0 ]] ; then
cat $TMPALRTLOG | mail -s "[$(hostname)] Alertlog Errors - $(date)" DBAMAIL > /dev/null
cat $ERRORFILE1 | while read LINE
do
ERROR="$(echo $LINE | grep -hie 'ORA-00600' -ihe 'ORA-07445' -ihe 'Errors in file' -ihe 'deadlock')"
if [[ -n $ERROR ]] ; then
echo $ERROR | mail -s "[$(hostname)] Alertlog Errors PAGE - $(date)" DBAPAGER > /dev/null
fi
done
fi
fi
mv $ERRORFILE1 $ERRORFILE2
touch $ERRORFILE1
Labels
Thursday, December 18, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment