Avail script (avail)


Avail script (avail)


Description
required by Goto script
Lists available databases and their current state

Script

#!/bin/ksh
#
# filename: /home/oracle/avail
# file is used with /home/oracle/goto
#
# Description: Lists available databases and their current state
#               (running / not running)
#
# Modified 14-Jul-2000
#    - Change the test of sgadef.dbf to ora_pmon_SID to cater
#      V8.1 databases
#
if  [ -f /etc/oratab ] ; then
        ORATAB=/etc/oratab
else
        echo "oratab does not exist"
        exit 1
fi;
#
echo ""
echo "The following databases are available :"
echo ""
echo "ORACLE_SID        ORACLE_HOME             Running?"
echo ""
DBASES=`cat $ORATAB | awk 'BEGIN {FS=":"} $1 !~/^#/ {printf("%s:%s ",$1,$2)}'`
#
# Now check if the database is running
#
for name in $DBASES
do
DBSID=`echo $name | awk 'BEGIN {FS=":"} {print $1}'`
DBHOME=`echo $name | awk 'BEGIN {FS=":"} {print $2}'`
# test to see if db is running
#if  [ -f ${DBHOME}/dbs/sgadef${DBSID}.dbf ]
if [ $DBSID = "GCAgentHome" ]
then
ps -ef|grep emagent|grep -v grep >/dev/null
else
ps -ef|grep ora_pmon_${DBSID}|grep -v grep > /dev/null
fi
if [ $? = 0 ]
then
        DBRUN="yes"
else
        DBRUN="no"
fi
        echo "$DBSID            $DBHOME         $DBRUN"
done
exit 0

No comments:

Post a Comment