10-27-2008
Shell script using ssh remains connected at primary site
Hi All,
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,
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a script that performs an oracle export:
<snip>
if
then
exp / full=y file=${exp_file} log=${exp_log} direct=y feedback=1000000 STATISTICS=NONE buffer=20000000
else
exp / full=n owner=${schema_name} file=${exp_file} log=${exp_log} direct=y feedback=1000000... (4 Replies)
Discussion started by: Squeakygoose
4 Replies
2. Shell Programming and Scripting
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
3. Shell Programming and Scripting
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... (0 Replies)
Discussion started by: a1_win
0 Replies
4. Shell Programming and Scripting
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... (1 Reply)
Discussion started by: a1_win
1 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I have ssh'd into a UNIX server at work from my linux desktop and executed a tar command to backup up some directories to a tape drive. I was wondering would the tar command still execute to completion if I closed my terminal console on my desktop that is connected to the server, would the... (1 Reply)
Discussion started by: mojoman
1 Replies
6. UNIX for Advanced & Expert Users
Hi !
How to export ENV variables, which remains set for all the shell
Example :-
Login :myID
Pwd : **** -> Here my ID .profile is executed. Let say I set MYENV variable
Kisses% rlogin ABC -l XXXGroupID -> I login into a remote Solaris Server ABC
password : **** -> "XXXGroupID's... (1 Reply)
Discussion started by: dashok.83
1 Replies
7. Shell Programming and Scripting
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
8. Shell Programming and Scripting
Hello all,
I want to display all the user logged last week and know the time tnat they are connected. I have been looking for a solution in the Forum, but I didn't find.
Thanks in advance (4 Replies)
Discussion started by: ahernandez
4 Replies
9. Shell Programming and Scripting
Hello,
i have a network device that users connect to using ssh. I have a script that connects to the device and has to echo something to other connected people. How can this be established?
ssh user@device 'echo Hello > /dev/console' doesn't seem to do the trick. (2 Replies)
Discussion started by: trafo23
2 Replies
10. Solaris
Hello,
I have a machine with Solaris 8, and it has multiple interfaces that are connected to the same network which means they all have metric 0 (1 hop) to the default gateway.
assume:
* e1000g0: 10.1.1.70
* e1000g2: 10.1.1.72
* e1000g4: 10.1.1.74
* e1000g5: 10.1.1.76
* gateway:... (11 Replies)
Discussion started by: aeg
11 Replies
LEARN ABOUT DEBIAN
ssh-argv0
SSH-ARGV0(1) BSD General Commands Manual SSH-ARGV0(1)
NAME
ssh-argv0 -- replaces the old ssh command-name as hostname handling
SYNOPSIS
hostname | user@hostname [-l login_name] [command]
hostname | user@hostname [-afgknqstvxACNTX1246] [-b bind_address] [-c cipher_spec] [-e escape_char] [-i identity_file] [-l login_name]
[-m mac_spec] [-o option] [-p port] [-F configfile] [-L port:host:hostport] [-R port:host:hostport] [-D port] [command]
DESCRIPTION
ssh-argv0 replaces the old ssh command-name as hostname handling. If you link to this script with a hostname then executing the link is
equivalent to having executed ssh with that hostname as an argument. All other arguments are passed to ssh and will be processed normally.
OPTIONS
See ssh(1).
FILES
See ssh(1).
AUTHORS
OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
Theo de Raadt and Dug Song removed many bugs, re-added newer features and created OpenSSH. Markus Friedl contributed the support for SSH
protocol versions 1.5 and 2.0. Jonathan Amery wrote this ssh-argv0 script and the associated documentation.
SEE ALSO
ssh(1)
Debian Project September 7, 2001 Debian Project