#!/bin/ksh # ----------------------------------------------------------------------- # Filename: namesmon.ksh # Purpose: Check if the Oracle Names Server is functioning. # Author: Frank Naude, Oracle FAQ # ----------------------------------------------------------------------- NAMESERVER=oranamesrvr0 ORACLE_SID=oranames ORATAB=/var/opt/oracle/oratab MAILTO=address\@domain.com TESTENTRY=orcl ORACLE_HOME=`grep "^${ORACLE_SID}:" $ORATAB | cut -d: -f2 -s` PATH=:$ORACLE_HOME/bin:$PATH # # Look if Oracle Names Server is installed on this machine # if [ ! -x $ORACLE_HOME/bin/namesctl ] ; then echo The Oracle Names Server is not installed on this machine or echo environment setup is incorrect!!! return -1 fi # # Check if the nameserver process is running... # RC=`ps -ef | egrep '/bin/names' | egrep -v 'grep' | awk '{print $2}'` if [ "${RC}" = "" ]; then echo "Oracle Names Server $NAMESERVER is DOWN!!!" /bin/mail ${MAILTO} <<-EOF # Note the TAB chars Subject: Names Server Down!!! `date` - Oracle Names Server $NAMESERVER is DOWN!!! EOF return -2 fi # # Check if the nameserver resolve names... # RC=`namesctl <<-EOF | grep normal set server $NAMESERVER query $TESTENTRY exit EOF` if [ "${RC}" = "" ] ; then echo "Names Server doesn't resolve names!!!" /bin/mail ${MAILTO} <<-EOF Subject: Names Server doesn't resolve names!!! `date` - Oracle Names Server $NAMESERVER doesn't resolve names!!! EOF return -3 fi