![]() |
|
|
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 |
| mail.alert: Losing ./qfm4TKt04M014942 | panylinux | SUN Solaris | 0 | 05-29-2008 09:35 PM |
| need to send alert mail | smurala | Shell Programming and Scripting | 1 | 03-05-2008 10:17 AM |
| Sendmail [279] [ID 702911 mail.alert] ERROR!!! | louisd11 | SUN Solaris | 5 | 12-15-2006 03:31 PM |
| Shell script to send email alert for core dump | rtatineni | SUN Solaris | 1 | 08-17-2006 03:33 PM |
| Help? Any method to send system alert email? | ITJacky | UNIX for Dummies Questions & Answers | 1 | 06-03-2006 08:29 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to use SSH to connect to Primary DB and send alert mail
Hi All,
AIX 5.3 64 bit: I am using the below shell script the objective is: Objective: ======== 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 through the below shell script: How could I connect to the primary database in the below shell script using SSH? #----------------------------------------------------------------------------- # Use SQL*Plus to query the MAX(SEQUENCE#) from both databases V$LOG_HISTORY view. If the STANDBY appears to be falling behind, send alert mail.. #----------------------------------------------------------------------------- _OutFile=/tmp/stdby_chk_$$.out sqlplus -s /nolog << __EOF__ > ${_OutFile} 2>&1 whenever oserror exit 99 connect / as sysdba set verify off whenever sqlerror exit 6 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; whenever sqlerror exit 7 connect ${_PriUnPwd} whenever sqlerror exit 8 col logseq_on_primary new_value V_PRIMARY_LOGSEQ select /*+ rule */ max(h.sequence#) logseq_on_primary from sys.v_\$log_history h, sys.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; whenever sqlerror exit 9 begin if &&V_STDBY_LOGSEQ < &&V_PRIMARY_LOGSEQ - 2 then -- if &&V_PRIMARY_FILECNT > &&V_STDBY_FILECNT then -- raise_application_error(-20001, '${_StdbyOraSid} is falling behind; datafile(s) were added to PRIMARY'); -- elsif &&V_PRIMARY_FILECNT < &&V_STDBY_FILECNT then -- raise_application_error(-20002, '${_StdbyOraSid} is falling behind; datafile(s) were dropped from PRIMARY'); -- else -- raise_application_error(-20000, '${_StdbyOraSid} is falling behind.'); -- end if; -- end if; end; / exit success __EOF__ Anyone could help would be appreciated!! Thanks for your time! Regards, |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|