Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Need Script to check if database is up or down
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
"**********************************************************************"
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 copyover the
> times. > > Need help, please respond to john.jones_at_duke.edu if you have asolution.
> > -- > 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
![]() |
![]() |