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

Home -> Community -> Usenet -> c.d.o.server -> Re: Is database up

Re: Is database up

From: Frederic DEBRUS <frederic.debrus_at_ces-cdr.be>
Date: 20 Oct 1999 14:32:16 GMT
Message-ID: <01bf1b07$dc4cb980$3e35a99e@gal159a>


You can try to use the following :

#!/bin/ksh
#
# DEBRUS Frederic
# DBSTATUS.SH <Instance>
#

. /etc/profile
. /opt/local/bin/oraprofile
NAMESERVER=oranamesrvr1

SendMsg()
{
echo $*
}  

IsOracleProcessRunning()
{
ps -ef | egrep $INSTANCE | egrep $PROCESS > /dev/null 2>&1 }

IsNamesRunning()
{
ps -ef | egrep '/bin/names' | egrep -v 'grep' > /dev/null 2>&1 }

IsListenerRunning()
{
ps -ef | egrep '/bin/tnslsnr' | egrep -v 'grep' > /dev/null 2>&1 }

IsNamesResolving()
{
namesctl query $1 | grep normal > /dev/null }

IsListenerUp()
{
lsnrctl status $1 > /dev/null
}

# Main

#
# check if names server is running
#

IsNamesRunning || SendMsg "Names Server - $NAMESERVER - DOWN"

#
# check if listener is running
#

IsListenerRunning || SendMsg "Listener - DOWN"

#
# check if all Oracle process are running
#

for INSTANCE in $*
do
 DOWN=0
 for PROCESS in pmon dbwr lgwr smon
 do

    IsOracleProcessRunning || DOWN=1
 done
 [ $DOWN = 1 ] && SendMsg "Oracle Server - $INSTANCE - DOWN"

 #
 # check if names resolve address
 #

 IsNamesResolving $INSTANCE ||
 SendMsg "Names Server - $NAMESERVER - Oracle Instance - $INSTANCE - UNRESOLVED"
 #
 # check if listener is up 
 #

 IsListenerUp $INSTANCE || SendMsg "Listener - $INSTANCE - DOWN" done

Hope this help...

Jim Gregory <JG200024_at_NCR.com> wrote in article <380dbe7e_at_rpc1285.daytonoh.ncr.com>...
> I'm trying to write a unix script to be run under cron that needs to > determine if a database instance is up on a remote box. This will run under
> the oracle user with no root privs and rsh, rlogin, etc. is not available.

> 
> So far the only way I've determined how to do this is to try and log into
> the remote database via "sqlplus user/pass_at_servicename,   and then pipe
the
> output to grep looking for oracle error ORA 01034 "Oracle not available".
> 
> Any one have a better, cleaner solution?
> 
> Thanks in Advance
> 
> --
> Jim Gregory
> Principal Consultant for Keane, Inc.
> Currently assigned to NCR
> "Opinions are my own and do not reflect
>   those of Keane or my clients"
> 
> 
> 
Received on Wed Oct 20 1999 - 09:32:16 CDT

Original text of this message

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