RE: Script to find error in alert log

  • From: "Dwyer, Brian" <Brian.Dwyer@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
  • To: <ora-apps-dba@xxxxxxxxxxxxx>
  • Date: Wed, 30 Apr 2008 10:07:38 +0100

***************************************************************************
Internet email is not to be treated as a secure means of communication.
North Yorkshire Police monitors all internet email activity and content.
This communication is intended for the addressee(s) only.
Please notify the sender if received in error. Unauthorised use or
disclosure of the content may be unlawful. Opinions expressed in this
document may not be official policy.  Thank you for your co-operation.
***************************************************************************

This is a script that we used.
 
#!/bin/kasha
 
set_sid()
{
  ORACLE_SID=PRD1   
  export ORACLE_SID
  ORACLE_HOME=/u21/app/oraprdb/product/8.1.7
  export ORACLE_HOME
  PATH=$ORACLE_HOME/bin:${PATH}
  export PATH
 
LD_LIBRARY_PATH=/u21/app/oraprdb/product/8.1.7/lib:/usr/dt/lib:/usr/open
win/lib
  export LD_LIBRARY_PATH
}
 
get_alert_log()
{
echo "
     set pages 0 feedback off
     select value from v\$parameter where name =
'background_dump_dest';" | \
     sqlplus -s "/ as sysdba" | \
read bdump
export bdump
ALERT_LOG=${bdump}/alert_${ORACLE_SID}.log
}
 
check_alert_log()
{
SIZE=`ls -l $ALERT_LOG | awk '{print $5}'`
export SIZE
if [ -f $ALERT_LOG.size ] 
then
   START=`cat $ALERT_LOG.size`
   dd if=$ALERT_LOG of=/tmp/alert.log bs=$START skip=1
   CHECKFILE=/tmp/alert.log
else
   CHECKFILE=$ALERT_LOG
fi
 
if [ "`grep 'ORA-' $CHECKFILE`" ] 
then
  /usr/lib/sendmail oraprdb < ${CHECKFILE}     --    Email
else
 echo "No new errors in alert log ${ALERT_LOG}\n"
fi
if [ $SIZE -gt $MAXSIZE ] 
then
 cp $ALERT_LOG $ALERT_LOG.$DATE
 compress $ALERT_LOG.$DATE
 > $ALERT_LOG
 rm $ALERT_LOG.size
else
 echo $SIZE > $ALERT_LOG.size 
fi
}
 
pmon=`ps -ef | egrep ora_pmon_PRD1 | grep -v grep` > /dev/null
 
if [ "${pmon}" != "" ]
then
  MAXSIZE=1048576
  export MAXSIZE
  DATE=`date +%d%m%Y`
  export DATE
  set_sid
  get_alert_log
  check_alert_log
fi


  _____  

From: ora-apps-dba-bounce@xxxxxxxxxxxxx
[mailto:ora-apps-dba-bounce@xxxxxxxxxxxxx] On Behalf Of k srinivas
Sent: 30 April 2008 06:58
To: ora-apps-dba@xxxxxxxxxxxxx
Subject: Script to find error in alert log


Hi DBAS,
 
Please help me out , I am looking for script to find errors in alert log
so as to enable it in crontab.
Any prompt turnaround will be greatly helpful ..
 
Thanks in advance ..
 

Other related posts: