Hi,
I am not much familer with Shell Scripting. As per requirement we want to monitor Logs and send Alert if specified Error present in the Log. I got below code from some social Network.
The Problem is it's Sending "Null message body; hope that's ok" Message if there is no Errors on the File. We set it in Cronjob, So every 30minutes I am getting Empty Body Mail. We want to ignore null body message. So, Kindly please help on this.
Code:
#!/bin/bash
string='ORA-01591'
pathloc='/opt/apps/shared/opentext/vcm/logs/VgnVCM1-runtime.log'
len=${#string}
if [ ! -e DBErrors ] ; then
grep $string $pathloc > DBErrors
mail -s "ORA-01591: lock held by in-doubt distributed transaction Error" Jayaram.Ponnusamy@gmail.com < DBErrors
else
if [ ! -e $string ] ; then
comm -23 <(grep $string $pathloc) DBErrors | mail -s "ORA-01591: lock held by in-doubt distributed transaction Error" Jayaram.Ponnusamy@gmail.com
fi
grep $string $pathloc > DBErrors
fi
Thanks