archive sil (sh)


25 01 * * * /usr/local/bin/arc_sil /arc_AZKKDB3

[ora92@dbcluster4 ora92]$ cat /usr/local/bin/check_ora_AZKKDB
# File-name: check_alert.sh
#-----------------------------------------------------
# Checks Oralce alert log files for all databases
# 1. Gets a database name from oratab.
# 2. Makes a copy of the alert file for each day
# 3. Cleans the alert log file
# 4. Checks ORA errors in the alert log file
# 5. Sends an e-mail with results to DBA
#-----------------------------------------------------
#!/bin/ksh
ORACLE_BASE=/oracle/ora92; export ORACLE_BASE
TMPDIR=/tmp; export TMPDIR
ORATAB=/etc; export ORATAB
#------------------------------------------------------------------------
# Get the list of the Oracle instances from the oratab file
#------------------------------------------------------------------------
#cat ${ORATAB}/oratab | while read LINE
#do
# case $LINE in
# \#*) ;; #comment-line in oratab
# *)
# ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
# if [ "$ORACLE_SID" = '*' ] ; then
# ORACLE_SID=""
# fi
 ORACLE_SID=AZKKDB
 export ORACLE_SID;
 ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`; export ORACLE_HOME
 SHLIB_PATH=$ORACLE_HOME/lib:/usr/lib; export SHLIB_PATH
 LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH
#------------------------------------------------------------------------
# Initialization
#------------------------------------------------------------------------
 l_err=0
 l_date=`date '+%m%d%H%M%S'`
 l_log=/usr/local/bin/check_alert_${ORACLE_SID}.log
 l_alertfile=${ORACLE_BASE}/${ORACLE_SID}/bdump/alert_${ORACLE_SID}4
echo `date '+%m/%d/%y %A %X'` "*** log BEGIN ***" > $l_log
 echo "----------------------------------------------------------------" >> $l_log
 echo "Script : "$0 >> $l_log
 echo "Database : "$ORACLE_SID >> $l_log
 echo "Server : "`uname -n` >> $l_log
 echo "----------------------------------------------------------------\n" >> $l_log
#------------------------------------------------------------------------
# Verify the existance of the Oracle environment variables
#------------------------------------------------------------------------
 if test `env | grep ORACLE_SID | wc -l` -ne 1
 then
 l_err=1
 echo "ORACLE_SID is not set \n" >> $l_log
 fi
if test `env | grep ORACLE_HOME | wc -l` -ne 1
 then
 l_err=1
 echo "ORACLE_HOME is not set \n" >> $l_log
 fi
#------------------------------------------------------------------------
# Check the alert log file for any errors and clean it
#------------------------------------------------------------------------
 echo ${l_alertfile}.log
 if ( test -r ${l_alertfile}.log )
 then
 #---------------------------------------------------------
 #Check the alert log file for database startup and shutdown
 #---------------------------------------------------------
 if test `grep "ALTER DATABASE CLOSE" ${l_alertfile}.log | wc -l` -ne 0
 then
 l_err=1
 echo "DIKKAT DB SHUTDOWN YAPILMIS!\n" >> $l_log
 fi
 if test `grep "alter database open" ${l_alertfile}.log | wc -l` -ne 0
 then
 l_err=1
 echo "DIKKAT DB STARTUP YAPILMIS!\n" >> $l_log
 fi
 echo ${l_alertfile}.log
 if test `grep "ORA-" ${l_alertfile}.log | wc -l` -ne 0
 then
 l_err=1
 echo "There is an error in the Oracle alert log file!\n" >> $l_log
 grep "ORA-" ${l_alertfile}.log >> $l_log
 # Make a copy of the alert log file only if it's not empty
 #----------------------------------------------------------
# if test `cat ${l_alertfile}.log | wc -l` -ne 0
# then
# cat ${l_alertfile}.log >> ${l_alertfile}.${l_date}
# rm ${l_alertfile}.log
# touch ${l_alertfile}.log
# fi
 else
 echo "There are NO errors in the alert log file" >> $l_log
 fi
 fi
# Make a copy of the alert log file only if it's not empty
 #----------------------------------------------------------
 if test $l_err -eq 1
 then
 if test `cat ${l_alertfile}.log | wc -l` -ne 0
 then
 cat ${l_alertfile}.log >> ${l_alertfile}.${l_date}
 rm ${l_alertfile}.log
 touch ${l_alertfile}.log
 fi
 fi
echo "\n----------------------------------------------------------------" >> $l_log
 echo `date '+%m/%d/%y'` `date '+%H:%M:%S'` "*** log END ***" >> $l_log
#------------------------------------------------------------------------
# Send errors to DBA
#------------------------------------------------------------------------
 if test $l_err -eq 1
 then
 mail -v -s "ORA ERROR - AZKKDB4-RAC" dba@bankAZKKDB.com.tr < $l_log
 if [[ `grep "ORA-19504" $l_log|wc -l` -gt 0 ]] ;then
 /usr/local/bin/send_one_sms.sh "ALARM:AZKKDB loglar icin yer kalmadi"
 elif [[ `grep "ORA-16014" $l_log|wc -l` -gt 0 ]] ;then
 /usr/local/bin/send_one_sms.sh "ALARM:AZKKDB loglar icin yer kalmadi"
 fi
# mailx -s "oracle : `uname -n` : $ORACLE_SID" "oracle" > /dev/null < $l_log
 continue
 fi
# esac
#done
# -----------------------------------------------------------------------
# Olusan logfile lar ve trace file lar 30 gun kalacak sekilde silinir.
# -----------------------------------------------------------------------
find ${ORACLE_BASE}/${ORACLE_SID}/bdump/alert* -mtime +30 -exec \rm {} \;
find ${ORACLE_BASE}/${ORACLE_SID}/bdump/*.trc -mtime +30 -exec \rm {} \;
#-----------------------------------------------------
# End of file
You have new mail in /var/spool/mail/ora92

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: