Archivelog monitoring Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Archivelog monitoring Script
# 1  
Old 04-23-2009
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
# 2  
Old 04-23-2009
Bug 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 Smilie

Regards,
HKansal
# 3  
Old 04-23-2009
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...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Monitoring Script

Hello All, I have written a script which will grep for error codes in a file and if the count for the same is about 500 it will send and smpp alert. Here is my code. #!/bin/bash #########################################################################################################... (3 Replies)
Discussion started by: Siddheshk
3 Replies

2. UNIX for Advanced & Expert Users

ldapsearch in monitoring script without bind password written in script

Hi I do a very simple monitoring of our OpenLDAP (runs in cronjob and generate alerts if unsuccessfull) $ ldapsearch -h hostname.domain -D "cn=monitor_user,ou=People,dc=organisation" -w "password" -b "dc=organisation" -x "(&(cn=monitor_user)(ou=People))" dn | grep -v version dn:... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

3. Red Hat

monitoring script

Hi, I ned to monitor the memory for the red-hat machine,when its reaches a threshold value like 2GB then a mail should be sent as soon as it finds the the value is met can you suggest me which is the best way to do this? (2 Replies)
Discussion started by: sriniv666
2 Replies

4. Shell Programming and Scripting

Monitoring script

Hi, I want to write script that monitors particular ports in a server. I completed the script but.... If the server is restarted i need manually start the script.. Is there any way i can make the script start by it self after the server reboot........ Thanks, Firestar (4 Replies)
Discussion started by: firestar
4 Replies

5. Shell Programming and Scripting

Help with Monitoring script

Hi Gurus, Currently I am learning UNIX through online forums and unix blogs. I have the below requirement. I need to write a script to monitor server processes. For example, there are 3 processes currently running on the server.(java, pmrepagent, pmserver). If any of the process goes down,... (2 Replies)
Discussion started by: svajhala
2 Replies

6. Shell Programming and Scripting

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>> ... (1 Reply)
Discussion started by: anjum.suri
1 Replies

7. Shell Programming and Scripting

IP Monitoring Script

Dear All, I am new to Shell Programming, but I need a script which will monitor the different IP's in the live logs. Condition:- The script will monitor the logs continously and should print only those IP's which exists more than 3 times per day. Please do help me. Thanks and... (1 Reply)
Discussion started by: akhtar.bhat
1 Replies

8. Solaris

Monitoring Script

Hi, I want to write a script that will monitor cpu,mem usage and disk usage for entire day and data will be redirected to file, (4 Replies)
Discussion started by: manoj.solaris
4 Replies

9. UNIX for Advanced & Expert Users

monitoring script

i have a unix batch written in c, dealing with really time-consuming database operations i want to write a ksh script to monitor its performance. which items i should monitor? do you have any suggestions? 1)cputime 2)swap area 3)pmem 4) 5) what else? (1 Reply)
Discussion started by: gfhgfnhhn
1 Replies

10. UNIX for Dummies Questions & Answers

monitoring script

hi can someone help me to write a script to monitor the growth of the directory running at 5 hours interval and then pipe it to a file :(? i only know the manual command "du -sk" and the worst i dun know anything about script. (3 Replies)
Discussion started by: legato
3 Replies
Login or Register to Ask a Question