#!/bin/bash
Daily_Log=/tmp/alert_log_check_daily.txt
MAIL_SUBJ="PROD:WARNING HOST: "
MAIL_RECIPIENT="tyagi.ankur07@gmail.com"
HOST_NAME=`hostname -a`
num_last_line=$1
#shows alert log tail from adrci
$ORACLE_HOME/bin/adrci exec="show homes"|grep rdbms | while read file_line
do
echo "################################################################################"
echo " adrci alert log contents " $file_line >> $Daily_Log
echo "#################################################################################"
#adrci exec="set homepath $file_line;show alert -tail -f"
adrci exec="set homepath $file_line; show alert -p \\\"message_text like '%ORA-%' and originating_timestamp > systimestamp-1\\\" $num_last_line"
done
num_errors=`grep -c -e 'TNS' -e 'ORA' $Daily_Log`
if [ $num_errors != 0 ]
then
MAIL_SUBJ=$MAIL_SUBJ$HOST_NAME" Errors Found in Daily Alert Summary"
mailx -s "$MAIL_SUBJ" $MAIL_RECIPIENT < $Daily_Log
fi
No comments:
Post a Comment