Here a fast little script I wrote that can be ran every minute

Emails only when it finds a new message

And pages if it finds a new message between 6pm and 5am

 

FPATH=/prod/dba/scr

autoload f_xmail

 

logfile=/prod/dba/logs/`cat /prod/dba/sys_data/newpath`/misc_logs/chk_alerts.log

 

echo "$(date +%y-%m-%d_%H:%M) -------- BOK ----------------- $$" >> $logfile

for i in DB1 DB2; do

   typeset -l sub=$(echo $i |cut -c1)

   alert_log="/prod/dump/$sub/alert_$i.log"

   if [ -f $alert_log ]; then       #if you don't find an alert log its ok just exit

        line_file="/prod/dump/$sub/ora_line"

        if [ ! -f $line_file ]; then

            echo 0 > $line_file

        fi

        last_line=$(cat $line_file)

        new_line=$(cat $alert_log |wc -l)

        if [ $new_line -lt $last_line ]; then    #then the alter log must have been deleted and recreated

              last_line=0

        fi

 

        if [ $(tail +$((last_line + 1)) $alert_log |grep ORA- |wc -l) -gt 0 ]; then

                echo "$(date +%y-%m-%d_%H:%M) NEW ORA Messages Found" >> $logfile

                (echo "From: chk_alerts.ksh"

                 echo "Subject: ORA messages found for $i \n"

                 cat $alert_log ) |mail dba@lechateau.ca                 #mail the entire log when new messages are found

                if [[ $(date +%H%M) -lt 0600 || $(date +%H%M) -gt 1800 || $(date +%u) -gt 5 ]]; then #nobody is around page also

                        echo "$(date +%y-%m-%d_%H:%M) Nobody is at work so paging also" >> $logfile

                        f_xmail pager ORA messages found for $i

                fi

        fi

        echo $new_line > $line_file

   else

      echo "$(date +%y-%m-%d_%H:%M) NO alert_log found to scan" >> $logfile

   fi

done

 

 

-----Original Message-----
From: Michael Kline [mailto:[EMAIL PROTECTED]
Sent: Friday, March 21, 2003 1:40 PM
To: Multiple recipients of list ORACLE-L
Subject: Script to check for errors

 

Anyone have a "simple" script to scan an alert

log for errors and email a report if found?

 

Customer wants something to run "often", but only

email when an error is found. I've got something

that does a bit of that and runs twice a day, but

always sends out.

 

Thanks.

 

Maks.

 

Reply via email to