![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Archivelog monitoring Script | anjum.suri | Shell Programming and Scripting | 1 | 04-23-2009 01:43 PM |
| UNIX script to check archivelog backups | anjum.suri | UNIX for Dummies Questions & Answers | 1 | 03-25-2009 07:58 PM |
| Job monitoring script | Love | High Level Programming | 1 | 06-13-2006 09:56 AM |
| CPU monitoring script | alpha_manic | UNIX for Advanced & Expert Users | 4 | 08-25-2005 11:08 AM |
| monitoring script | legato | UNIX for Dummies Questions & Answers | 3 | 03-21-2005 07:34 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 Last edited by Franklin52; 04-23-2009 at 01:50 PM.. Reason: adding code tags |
|
||||
|
Hello,
I assume that you are able to get the o/p in a plain file. Here are the steps that you should follow:
Actions according to value of counter: 1 this is ur database 2 this is ur filename 3 take col 4 and 5 - use awk or cut 4 same as counter value 3 5 this is the status (I would take "Successful"/"failed" only) at each step echo these values and use tabs to separate them, eg: Code:
echo "\t<value>" adjust the number of tabs as u need, u'll need to tweak a bit ![]() Regards, HKansal |
|
||||
|
You can also tackle it this way and fidget with space in your echo/print statement:
Code:
print "Header2 Header2 Header3 Header4,etc " > $TMP_FILE
print "------etc" >>$TMP_FILE
for i in `chkbck`
do
f1=`echo $i | cut -d"_" -f3`
f2=`$i | cut -d"/" -f6`
f3=`egrep -i 'Starting backup*' $i`
f4=`egrep -i 'Finished backup*' $i`
if egrep -i 'exit status [^0]' $i
then
f5="Backup Failed"
else
f5="Backup Successful"
fi
print $f1 $f2 $f3 $f4 $f5 >> $TMP_FILE
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|