The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #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 01:50 PM.. Reason: adding code tags
  #2 (permalink)  
Old 04-23-2009
hkansal hkansal is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 69
Smile Logic only

Hello,

I assume that you are able to get the o/p in a plain file. Here are the steps that you should follow:
  1. Initiate a counter from 1
  2. Loop through the file line-wise
    1. Operate on current line according to value of counter
    2. Increment counter; reset to 1 if value is 6

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>"
use \c to keep output on same line.

adjust the number of tabs as u need, u'll need to tweak a bit

Regards,
HKansal
  #3 (permalink)  
Old 04-23-2009
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
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
Just a thought...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0