Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Is database up
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 #
# # check if listener is up #
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 pipethe
> 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