Could anyone please help?
I have written a small program that's actually working fine for me and extracting all the details I required. What code does is, it goes to all archivelog directories and see if archivelog backup was failed or successful
<<CODE>>
Code:
TMP_FILE='/ora/rman/scripts/tmp_chk.log'
chkbck ()
{
for i in `ls /ora/rman/logs/`;
do
find /ora/rman/logs/$i/backup_a*.log -mtime -1 2>/dev/null
done
}
for i in `chkbck`;
do
print $i | cut -d"_" -f3
print $i | cut -d"/" -f6
egrep -i 'Starting backup*' $i
egrep -i 'Finished backup*' $i
if egrep -i 'exit status [^0]' $i
then
print "Backup Failed"
else
print "Backup Successful"
fi
done > $TMP_FILE
<<CURRENT OUTPUT>>
Code:
ABC
backup_arch_CBPAP1P_22Apr09-155751.log
Starting backup at 22-APR-2009 15:57:58
Finished backup at 22-APR-2009 15:59:15
Backup Successful
XYZ
backup_arch_KANAR1P_22Apr09-160303.log
Starting backup at 22-APR-2009 16:03:15
Finished backup at 22-APR-2009 16:04:44
Backup Successful
Now, what I need is if I get this output in a email with proper headings and formatting.
<<DESIRED OUTPUT IN EMAIL>>
Code:
Database FileName Backup Start Backup End Status
--------- --------- ------------- ----------- -------
ABC backup_arch_ABC_22Apr09-155751.log 22-APR-2009 15:57:58 22-APR-2009 15:59:15 Backup Successful
XYZ backup_arch_XYZ_22Apr09-160303.log 22-APR-2009 16:03:15 22-APR-2009 16:04:44 Backup Successful
Could anyone please help me nicely formatting it?