#!/bin/bash # Purpose: Detecting ORACLE Errors from any log file and send email # Author: Arvind Toorpu # Note : The script must run as a cron-job. # Last updated on : 15-Feb-2016 ## edit FILE to log file u want to check for errors # ----------------------------------------------- # Store path to commands FILE=/u01/app/oracle/admin/bin/test_error.txt # Store email settings AEMAIL="abcd@anyorg.com" ASUB="ORACLE Error - $(hostname)" AMESS="Warning - ORACLE errors found on $(hostname) @ $(date). See log file for the details /u01/app/oracle/admin/bin/test_error.txt" OK_MESS="OK: NO ORACLE Error Found." WARN_MESS="ERROR: ORACLE Error Found." # Check if $FILE exists or not if test ! -f "$FILE" then echo "Error - $FILE not found or mcelog is not configured for 64 bit Linux systems." exit 1 fi # okay search for errors in file error_log=$(grep -c -i "ORACLE error" $FILE) # error found or not? if [ $error_log -gt 0 ] then # yes error(s) found, let send an email echo "$AMESS" | mailx -s "$ASUB" $AEMAIL <<-EOF ### Below line can be removed if you dont want to receive last few lines of that alert log `tail -n -50 /u01/app/oracle/admin/bin/test_error.txt` EOF else # naa, everything looks okay echo "$OK_MESS" fi
“Knowing others is intelligence; knowing yourself is true wisdom. Mastering others is strength; mastering yourself is true power.” Arvind Toorpu
Friday, February 19, 2016
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment