Home » Infrastructure » Windows » Dos script to verify instance availability (MS Windows 2003 - Oracle 10.2.0.1)
Dos script to verify instance availability [message #432318] Mon, 23 November 2009 09:55 Go to next message
aashi1
Messages: 10
Registered: March 2007
Location: NEW YORK
Junior Member

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 Go to previous messageGo to next message
ThomasG
Messages: 3211
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.
Re: Dos script to verify instance availability [message #432887 is a reply to message #432318] Fri, 27 November 2009 01:01 Go to previous messageGo to next message
Kevin Meade
Messages: 2103
Registered: December 1999
Location: Connecticut USA
Senior Member
Nice one ThomasG. There used to be a word for these kinds of files. I think they call them a SENTINAL file.

Kevin
Re: Dos script to verify instance availability [message #432912 is a reply to message #432887] Fri, 27 November 2009 04:03 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

Since you are running on windows, and one of your task is to see the "instance availability". Just check the window's service

ex.
C:\>sc query OracleServiceORCL1| find "RUNNING"
        STATE              : 4  RUNNING


[Updated on: Fri, 27 November 2009 04:04]

Report message to a moderator

Re: Dos script to verify instance availability [message #443657 is a reply to message #432318] Tue, 16 February 2010 19:58 Go to previous message
eds4orafaq
Messages: 1
Registered: April 2007
Junior Member
I suggest you create a user just for monitoring and not use SYS.
Previous Topic: Running a batch file from oracle procedure
Next Topic: Oracle installers available in .msi format
Goto Forum:
  


Current Time: Thu Mar 28 04:29:06 CDT 2024