Script to Check Oracle Instance Availability

Check Oracle Instance Availability

The oratab file lists all the databases on a server:

$ cat /etc/oratab

##############

##/etc/oratab

##############

oradb1:/u01/app/oracle/product/8.1.7:Y

oradb2:/u01/app/oracle/product/8.1.7:Y

oradb3:/u01/app/oracle/product/8.1.7:N

oradb4:/u01/app/oracle/product/8.1.7:Y

The following script checks all the databases listed in the oratab file, and finds out the status (up or down) of databases:

##################

## ckinstance.ksh ##

##################

ORATAB=/etc/oratab

echo "`date` "

echo "Oracle Database(s) Status `hostname` :\n"

db=`egrep -i ":Y:N" $ORATAB cut -d":" -f1 grep -v "\#" grep -v "\*"`

pslist="`ps -ef grep pmon`"

for i in $db ; do

echo "$pslist" grep "ora_pmon_$i" > /dev/null 2>$1

if (( $? )); then

echo "Oracle Instance - $i: Down"

else

echo "Oracle Instance - $i: Up"

fi

done

Use the following to make sure the script is executable:

$ chmod 744 ckinstance.ksh

$ ls -l ckinstance.ksh

-rwxr--r-- 1 oracle dba 657 Dec 5 22:59 ckinstance.ksh*

Here is an instance availability report:

$ ckinstance.ksh

Mon Dec 31 11:44:12 IST 2007

Oracle Database(s) Status for DBHOST server:

Oracle Instance - oradb1: Up

Oracle Instance - oradb2: Up

Oracle Instance - oradb3: Down

Oracle Instance - oradb4: Up

Thanks

-Sasi Kumar. D

 

0 comments: