Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: How to know Oracle Down ?

Re: How to know Oracle Down ?

From: Sakthi , Raj <rajan_sakthi_at_yahoo.com>
Date: Tue, 31 Jul 2001 08:31:48 -0700
Message-ID: <F001.0035A265.20010731073651@fatcity.com>

You can use the following shell script and have it email you the error message . Th eemailing is not enabled in teh script because I use it for HP OpenView monitoring which reads the text out put constantly .

Database administrators Often encounter the need for a heartbeat machanism to
check The availability of Database and network connectivity . This script is to fulfill such need . This script could be called either by another script which emails the result
to the admin or this could be used by third party tools like HP OpenView .

        One point to note is that to check the network connectivity the script has to
Reside on the machine it is checking . Of course this could be modified to add further
Functionality . This is just a frame work .

#!/usr/bin/sh
###################################################################################################
#
# Auther : Raj Sakthi
#
# Modification History :
# 02/23/00 : Network Connectivity Checking was added
.
#
# *** THIS SCRIPT CHECKS FOR THE AVAILABILITY OF
INSTANCE ALONG WITH THE ****
# *** NETWORK CONNECTIVITY



#
# Usage : Pass SID as parameter.
# Example : sid_run orcl
#
#######################################################################################################
export CHECK_CONNECT=$$.CHECK_CONNECT
export READY=$$.good
SID=$1
rm -f $READY
print "
 connect a/aa@$SID
  host touch $READY
 exit " |
 sqlplus /nolog > $CHECK_CONNECT &
#
# Next we use a timer to check the sqlplus
hanging.........
#----------------------------------------------------------------
((timeout = 60))
while ((timeout -= 1)) && [[ ! -r $READY ]]

    do

        sleep 1
    done
#
# If the file Doesn't exist then we check for internal
connectivity …………..
#--------------------------------------------------------------------------------
if [ ! -f $READY ]
  then

         print "
         connect internal
         exit " |
         sqlplus /nolog > $SID_connect.log
         egrep 'Connected' $SID_connect.log >
/dev/null
      if [ $? = 0 ]
         then
         echo " Problem in Network connectivity of
$SID "
         else
         echo " Instance $SID is not responding "

#
# Here we decide that Database is unavailable Due to
SQLPLUS hanging .........
#-------------------------------------------------------------------------------
         exit 86
      fi

fi

   egrep 'ORA-01034|ORA-12224|ORA-12154' $CHECK_CONNECT > /dev/null
if [[ $? = 0 ]]; then

   echo "Instance '$SID' is NOT accessible, or invalid ORACLE_SID"
   rm $CHECK_CONNECT
   rm $READY
#
# Here instance is not available....staight and
simple..: )
#-----------------------------------------------------------------------------

   exit 86
else
#
# Check for INSTANCE availability by the specific
ORACLE error..........slick ..eh?!
#-------------------------------------------------------------------------

   grep 'ORA-01017' $CHECK_CONNECT > /dev/null   if [[ $? = 0 ]]; then

      echo "Instance '$SID' is UP and Accessible"     
     

   else
#
#To catch any other error .....
#

      echo "Instance '$SID' is HAVING UNKNOWN ERROR. \n Verify Instance internal state "

   fi
fi
rm $CHECK_CONNECT
rm $READY


Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Sakthi , Raj
  INET: rajan_sakthi_at_yahoo.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).
Received on Tue Jul 31 2001 - 10:31:48 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US