The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-23-2009
anjum.suri anjum.suri is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 8
Archivelog monitoring Script

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?

Last edited by Franklin52; 04-23-2009 at 02:50 PM.. Reason: adding code tags