Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Mailing Lists -> Oracle-L -> RE: probe database using OEM event or job

RE: probe database using OEM event or job

From: Reardon, Bruce (CALBBAY) <>
Date: Tue, 30 Sep 2003 16:54:29 -0800
Message-ID: <>

Can you just use the built in OEM event "Database UpDown" - though perhaps this only comes with the Diagnostics Pack for OEM.

As for a user defined test - You could just do something like "select user from dual" and hope it comes back if it can't connect - I haven't tried this. However, I think you'll find that user defined tests use the agent which connects via BEQ rather than via the listener so this won't help that much.

In the diagnostics pack you also have a listener SQLNet up down event

You could also write all this in a batch / perl / windows script / whatever language.

Have a look at Metalink notes to see all the events that are predefined: Note:69563.1 Subject: Overview of all the Event TCL files used by Enterprise Manager Note:69592.1 Subject: Quick reference of the events available in Enterprise Manager

The following forum has good info on user defined events:

	From: Christian Lang 31-Oct-00 15:03 
	Subject: User Defined SQL Test 

As for the sleep command - get it as its the easiest way (and part of resource kit) However, there are some (obscure) ways to emulate this functionality, eg:

44. How to pause in a batch for a preset number of seconds?

You can use the MS-DOS CHOICE.COM command for the purpose as the example below demonstrates
  @echo off
  echo Testing a delay, starting at ...
  echo.| time | find /v "new"
  choice /c:. /t:.,5 /n Pausing for five seconds   echo ending at ...
  echo.| time | find /v "new"
The choice command was introduced with MS-DOS 6. If you have an earlier MS-DOS version you can use my similar CHOOSE.EXE from

   For pauses longer than 99 seconds see the item #64. For better understanding the CHOICE parameter values, see the end of item #40.

Tom Lavedas points out that if one uses
  type nul | choice /c:. /t:.,5 /n Pausing for five seconds "The piping of the output from the TYPE command into CHOICE acts to defeat keyboard entry for the wait period."

Also see the later item "How can I write a "SLEEP" command to pause for a certain time?" for more on this question.

64. How can I write a "SLEEP" command to pause for a certain time?

If the delay you want is no more than 99 seconds the answer is fairly simple. All you need is the CHOICE command with appropriate options. For example the following batch pauses for ten seconds. You can, if you wish, break the wait by pressing the key b.   @echo off
  choice /cb /t:b,10 /n > nul
  rem ^ ^ "use b as the a break the wait key" For longer waits a loop is needed. The following batch sets a ten minute wait. Remove the line "echo %count_%" if you do not wish any progress report output.
  @echo off
  set count_=.
  set target_=...........
  echo %count_%
  choice /cb /t:b,60 /n > nul
  set count_=.%count_%
  if not "%count_%"=="%target_%" goto _loop   :_end
As so many items, parts of this one owe to the insights of Tom Lavedas, and parts are totally my own (un)doing.

For this and other useful (?) batch tricks see: Resources NT batch specific


UltraTech knowledge base

JSI Windows NT/2000 Tips, Tricks, Registry Hacks and more...

NT/Win2k scripting - good on bat differences between NT and DOS

Resources batch general:

Batfiles: The DOS batch file programming handbook and tutorial - good examples and hints / tricks  

DOS Batch Language: A personal view by Ted Davis - good intro for beginners


Multilingual Batch Programs

Programs by Prof. Timo Salmi - THE author of the alt.msdos.batch FAQ and then search for 184193 Mar 8 11:16
A collection of useful batch files and tricks, T.Salmi

Bruce Reardon

-----Original Message-----
Sent: Wednesday, 1 October 2003 9:54 AM
To: Multiple recipients of list ORACLE-L

On unix you could do:

while true; do tnsping ALIAS > out || mail < out; sleep 300; done;

(obviously you have to replace ALIAS and e-mail address there)
It will send you the tnsping output if it happens to fail. (you'll get a failure message after every 300 seconds though).

On windows, you could play around with %ERRORLEVEL% and goto cycles... You have to download sleep command though, Windows does not have such extraordinarily complicated scientific tool in standard package.


Can someone help me with this?
Running Oracle under win2000

I have an application server that occasionally looses connectivity with the listener on the database server although other application servers have no problems connecting. I get error 'Fatal NI connect error 12535' I would like to setup an OEM event (user defined?) or user defined job that must run from the application server having the problem which will test the connection to the listener on the database server (could be like a tnsping XXX) and if it is unsuccessful, notify me via email, pager, etc. has anyone done this?
Can it be done with a TCL script? Any samples appreciated?

John Baylis
Database Administrator
Canadian Forest Products Ltd.
Vancouver B.C. Canada
(604) 697-6476 (Office)
(604) 313-6054 (Cell)

Please see the official ORACLE-L FAQ:
Author: Reardon, Bruce (CALBBAY)

Fat City Network Services    -- 858-538-5051
San Diego, California        -- Mailing list and web hosting services
To REMOVE yourself from this mailing list, send an E-Mail message
to: (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L

(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Received on Tue Sep 30 2003 - 19:54:29 CDT

Original text of this message