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
Shell script using ssh remains connected at primary site a1_win Shell Programming and Scripting 5 10-27-2008 03:34 PM
shell script not connecting to primary from standby site a1_win Shell Programming and Scripting 0 10-23-2008 04:22 AM
shell script for archive purge regnumber Shell Programming and Scripting 5 10-14-2008 02:09 PM
Generic Shell Script to Archive a file mak1600 Shell Programming and Scripting 8 07-26-2008 08:51 AM
hacmp 5.3 primary and standby? itik AIX 2 06-27-2008 11:19 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-29-2008
a1_win a1_win is offline
Registered User
  
 

Join Date: Apr 2005
Posts: 33
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,
 

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 07:06 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