Friday, February 19, 2016

<p>#!/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 # -----------------------------------------------</p>

<p># Store path to commands FILE=/u01/app/oracle/admin/bin/test_error.txt</p>

<p># Store email settings</p>

<p>AEMAIL=&quot;abcd@anyorg.com&quot; ASUB=&quot;ORACLE Error - $(hostname)&quot; AMESS=&quot;Warning - ORACLE errors found on $(hostname) @ $(date). See log file for the details /u01/app/oracle/admin/bin/test_error.txt&quot; OK_MESS=&quot;OK: NO ORACLE Error Found.&quot; WARN_MESS=&quot;ERROR: ORACLE Error Found.&quot;</p>

<p> # Check if $FILE exists or not if test ! -f &quot;$FILE&quot; then  echo &quot;Error - $FILE not found or mcelog is not configured for 64 bit Linux systems.&quot;  exit 1 fi</p>

<p># okay search for errors in file error_log=$(grep -c -i &quot;ORACLE error&quot; $FILE)</p>

<p># error found or not? if [ $error_log -gt 0 ] then # yes error(s) found, let send an email  echo &quot;$AMESS&quot; | mailx -s &quot;$ASUB&quot; $AEMAIL <<-EOF  ### This can be removed if you dont want to receive last few lines of that alert log  &#96;tail -n -50 /u01/app/oracle/admin/bin/test_error.txt&#96;   EOF else # naa, everything looks okay  echo &quot;$OK_MESS&quot; fi </p>

No comments:

Post a Comment