shell script for primary and standby DB archive log check


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script for primary and standby DB archive log check
# 1  
Old 10-29-2008
shell script for primary and standby DB archive log check

Hi All,

OS:AIX 5.3 64 bits

I would like the below script to send alert mail with the message - "Standby logs falling behind Primary" to xyz@yahoo.com

Script
=====

#!/usr/bin/ksh

#-----------------------------------------------------------------------------
# Use SQL*Plus to query the MAX(SEQUENCE#) from both databases V$LOG_HISTORY # view. If the STANDBY appears to be falling behind, then send alert mail...
#-----------------------------------------------------------------------------
_OutFile=stdby_chk.out
sqlplus -s /nolog << __EOF__ > ${_OutFile} 2>&1
connect / as sysdba
set verify off

col logseq_on_standby new_value V_STDBY_LOGSEQ
select /*+ rule */ max(h.sequence#) logseq_on_standby
from v\$log_history h,
v\$parameter p
where h.thread# = to_number(decode(p.value,'0',1,p.value))
and p.name = 'thread';

col filecnt new_value V_STDBY_FILECNT
select count(*) filecnt
from v\$datafile;
exit;
__EOF__

ssh <username>@host.domain
export ORACLE_SID=<SIDNAME>
export ORACLE_HOME=<ORACLE_HOME_PATH>
export PATH=$ORACLE_HOME/bin:$PATH
_OutFile1=primary_chk.out
$ORACLE_HOME/bin/sqlplus -s /nolog << __EOF__ > ${_OutFile1} 2>&1
connect / as sysdba

col logseq_on_primary new_value V_PRIMARY_LOGSEQ
select /*+ rule */ max(h.sequence#) logseq_on_primary
from v\$log_history h,
v\$parameter p
where h.thread# = to_number(decode(p.value,'0',1,p.value))
and p.name = 'thread';

col filecnt new_value V_PRIMARY_FILECNT
select count(*) filecnt
from v\$datafile;
exit;
__EOF__
exit;

could anyone please share the exeperience in fulfilling this objective!!!

Thanks for your time!

Regards,
# 2  
Old 10-29-2008
shell script for primary and standby DB archive log check

Hi,

Standby archive logs should be falling behind by 2 than Primary archive logs.

For example:

If standby archive logs are at -> 498
Primary archive logs are at -> 500

Then alert mail should be sent to xyz@yahoo.com with the message "standby logs are behind primary"

Thanks for your help and time!!

Regards,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

2. Solaris

archive logs mount point space check script

I have the below shell script which is checking /archlog mount point space on cappire(solaris 10) server. When the space usage is above 80% it should e-mail. When i tested this script it is working as expected. -------------------------------------------------------------------------... (0 Replies)
Discussion started by: dreams5617
0 Replies

3. Shell Programming and Scripting

Archive shell script

Hi, I'm new to Unix shell scripting and my first task is proving to be tricky. Please help where you can with pointers, tips, or examples of script. I'm self learning from the internet. I need to archive off files to another write protected directory according to the file names. ex.... (0 Replies)
Discussion started by: gorses
0 Replies

4. Solaris

ifconfig primary & standby purpose

I have two ethernet interfaces nge0 and nge1. An IP assigned on nge0 is 10.10.10.1/24 and on nge1 is 20.20.20.1/24. I want to make nge0 as primary interface. My question here is, 1. Being nge0 as primary interface, if I ping to an IP 20.20.20.5, what will happen? 2. If the answer for the... (4 Replies)
Discussion started by: nthiruvenkatam
4 Replies

5. Shell Programming and Scripting

d. Write a shell script to count the number of accounts which belong to particular primary

guys, I am new shelll scripting.. this a question on passt exam paper, I was trying to solve it , I can not. the question is as follow? a. Write a shell script to count the number of accounts which belong to particular primary group in a standard UNIX system which uses local... (1 Reply)
Discussion started by: gurmad
1 Replies

6. Shell Programming and Scripting

shell script that will automatically check if specifed user is log in or not, in 30 seconds

guys I need emergency help with below shell script assignment..am new to shell script Write a Shell script to automatically check that a specified user is logged in to the computer. The program should allow the person running the script to specify the name of the user to be checked, the... (2 Replies)
Discussion started by: gurmad
2 Replies

7. Shell Programming and Scripting

Shell script using ssh remains connected at primary site

Hi All, OS:AIX 5.3 L My shell script using ssh remains connected at primary site and ssh doesn't get disconnected.What should be typed and where in the shell script below to do it. Shell script ======== #!/usr/bin/ksh v_standby=`sqlplus -s /nolog <<END @standby.sql END` echo... (5 Replies)
Discussion started by: a1_win
5 Replies

8. Shell Programming and Scripting

shell script not connecting to primary from standby site

Hi All, I am using below shell script using SQL*Plus to query the MAX(SEQUENCE#) from both databases V$LOG_HISTORY view.If the STANDBY appears to be falling behind by - 2, then alert mail should be sent... How could I achieve it with improving the below script. #!/usr/bin/ksh ... (0 Replies)
Discussion started by: a1_win
0 Replies

9. Shell Programming and Scripting

shell script for archive purge

I am writing a shell script for Archive Purge for the table having rows < 1 year. The shell script has to extract the rows from the table and write those extracted rows to a text file. Then from the text file, each rows will be read and deleted by means of delete query one by one. The fields will... (5 Replies)
Discussion started by: regnumber
5 Replies

10. AIX

hacmp 5.3 primary and standby?

Hi All, How do I determine if a hacmp 5.3 server is a primary or a standby? Thanks in advance. (2 Replies)
Discussion started by: itik
2 Replies
Login or Register to Ask a Question