Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Determining Oracle status
Barry:
I've seen responses saying to use TNSPING, but all that does is tell you if the listener is running on the destination machine. If the listener is up and no databases are up you will still get a positive response from TNSPING.
So, here's what we do. This ksh function snippet requires that your
remote database be defined in your TNSNAMES.ORA file. This function
attempts
to login with a completely invalid user id and password. If Oracle returns
a ORA-01017 ("invalid username/password; logon denied"), then the database
is available. Any other message and the database is not available.
I didn't write this, but I use it a lot.
Cheers,
Mike
#---------------------------------------------------------------------------IsTheDatabaseUp()
DBUP=T
echo "`date` (: $1 UP" >> ${OUTPUT}/logs/${BASEFILE}.log 2>&1
else
DBUP=F
echo "`date` (: $1 DOWN" >> ${OUTPUT}/logs/${BASEFILE}.log 2>&1
fi
return
}
#---------------------------------------------------------------------------
--- =========================================================================== Michael P. Vergara Oracle DBA Guidant CorporationReceived on Tue Sep 18 2001 - 16:51:04 CDT
(909) 914-2304
-----Original Message----- Sent: Tuesday, September 18, 2001 8:46 AM To: Multiple recipients of list ORACLE-L Hi all, I am trying to write a script in unix that determines if a specific oracle instance is available. I'm trying to avoid using the 'ps' command, so I thought the easiest method would be to connect via sqlplus - If it connects its up, if it doesn't then its unavailable. However, the problem is that when it isn't up, the script hangs and does not return anything - I think that this is because sqlplus by default gives you 3 attempts to logon, so even though the logon attempt failed, it is waiting for you to try again, so unfortunately I'm not getting a failed return code. If anybody could tell me how to change this so that it only allows 1 login attempt before 'kicking you out' or whether there is a better method to finding out the status of an instance, I would be extremely grateful to hear from you. TIA for any responses. Best Regards, Barry. -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Vergara, Michael (TEM) INET: mvergara_at_guidant.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (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).
![]() |
![]() |