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: Need Script to check if database is up or down

Re: Need Script to check if database is up or down

From: James Lorenzen <jlorenzen_at_my-deja.com>
Date: 2000/04/17
Message-ID: <8dfvf2$jl8$1@nnrp1.deja.com>#1/1

Here is a snippet of code that I use to check on the health of the databases. This code gets the location of the alert log that is checked for ORA- errors and some other conditions. If Oracle is not available, this little script exits with the error message. If it is available, I grep for a '===>' in the SQL output. IF its there, Oracle is up, if not, I issue the message. The code is run in the Korn shell and the BDDIR (background dump destination) is empty. This code is part of a much larger script.

HTH
    James

PS the back quote (`) is a Unix construct that executes the commands and returns the result of the commands.

# First get alert_log location for this instance   BDDIR=`echo "column value format a40\\nselect '===> ' || value val "\     ' from v$system_parameter where name ='\     " 'background_dump_dest' ;\\n"\
    "exit\\n" | $ORACLE_HOME/bin/sqlplus scott/tiger | awk '$1 ~ /\=\=\=\>/ {print $2}'`
  if [[ -z $BDDIR ]]
  then
    echo "Oracle Not Responding for $ORACLE_SID" >> $werrfile     echo

"**********************************************************************"

>> $werrfile

    error_check ;
    continue ;

In article <8dfo63$t7n$1_at_news.duke.edu>, "John Jones" <john.jones_at_duke.edu> wrote:
> Need immediate help from Unix System Guru's. I need a script that  checks if

> the database is up or down.  I DON'T need a script that checks for the
> existance of background processes.
>
> Here is my problem.  I rebuild a reporting database nightly, I copy
 over the
> datafiles, do a startup nomount (which starts the background  processes),
> then recreate the control file and start the database. Well if  something
> goes wrong on the control file or starting the database, the database  will
> not open, but the background processes are there. I tried writing a  script
> that uses SQL*Plus to connect, but if the database is not there my  script
> stops and prompts for another database connection, it will prompt  three (3)
> times.
>
> Need help, please respond to john.jones_at_duke.edu if you have a
 solution.
>
> --
> John Jones > Senior Oracle DBA > Duke University OIT
> john.jones_at_duke.edu

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Mon Apr 17 2000 - 00:00:00 CDT

Original text of this message

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