| Dos script to verify instance availability [message #432318] |
Mon, 23 November 2009 09:55  |
|
|
Hi All,
I am trying to write a DOS script to verify Oracle instance availability. I've developed the following script, but the requirement is to send an email notification if the instance is down (not available) for more than 10 minutes.
I don't know how to check the time interval in dos, if the instance is not available for more than 10 minutes. Please advice.
Here is the script I created in Dos.
set ORACLE_SID=orcl
rem -- Create SQL Script ---
echo connect sys/syspassword as sysdba; > %0.tmp
echo set echo off feed off pages 0 >> %0.tmp
echo whenever sqlerror exit sql.sqlcode >> %0.tmp
echo select * from global_name; >> %0.tmp
echo exit; >> %0.tmp
rem -- connect to database ---
sqlplus -s /nolog @%0.tmp >NUL:
if {%ERRORLEVEL%} == {0} (
echo Database %ORACLE_SID% is available
) else (
echo Database %ORACLE_SID% is NOT available
)
rem -- Cleanup --
del %0.tmp
Thanks,
|
|
|
|
| Re: Dos script to verify instance availability [message #432321 is a reply to message #432318] |
Mon, 23 November 2009 10:00   |
ThomasG
Messages: 2886 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
You could run the script every 10 minutes, and if the database is down and a certain file does NOT exist, then create the file.
If the database is up and the file exist, then delete that file.
If the database is down and the file exist, send the mail.
|
|
|
|
|
|
|
|
|
|