Script to find detail of all Oracle Home, Version, Edition on single Linux Server

List of Oracle homes,Version,Edition info on Server

Script is used to find all the oracle database running on one server with their detail regarding Version , Standard or Enterprise  and Oracle Home. This script helps in LINUX environment if you are having large no of database running on one server with different version and edition. By simple execute this shell script it will provide you the list of oracle home , DB name, version and edition running on oracle home.

Note: It read information from the /etc/oratab file to fetch all result. if you oratab is not configured properly the script is also not working properly.

Simply copy and paste this script as shell script and execute it sh script_name.

Script:

# oracle oratab file location
ORATAB=/etc/oratab
if [ ! -f $ORATAB ]
then
exit 1
fi
# Loop for every entry in ORATAB file
cat $ORATAB|grep -v '^$' | while read LINE
do        case $LINE in
\#*)
# Comment-Line in ORATAB
;;        *)
# Setup ORACLE_SID and ORACLE_HOME
# if third field in ORATAB is 'Y'
ORACLE_SID='echo $LINE | awk -F: '{print $1}' -'
if [ "$ORACLE_SID" = '*' ]
then
ORACLE_SID=""
fi
ORACLE_HOME='echo $LINE | awk -F: '{print $2}' -'
echo ORACLE_SID=$ORACLE_SID
echo ORACLE_HOME=$ORACLE_HOME
PATH10G=${ORACLE_HOME}/inventory/Components21/oracle.server/10.2.0.1.0/context.xml
if [ ! -f $PATH10G ];
then
set -- $(awk '{ print $1 , $2 ,$3 ,$4}' ${ORACLE_HOME}/inventory/globalvariables/oracle.server/globalvariables.xml|grep oracle_install_db_InstallType)
var=$4
else
set -- $(awk '{ print $1 , $2 , $3 , $4 , $5 ,$6}' ${ORACLE_HOME}/inventory/Components21/oracle.server/10.2.0.1.0/context.xml|grep s_serverInstallType\")
var=$6
fi
if [[ $var == *EE* ]];
then
echo 'Enterprise Edition'
else
echo 'Standard Edition'
fi
echo "Latest Oracle Version"
sh  ${ORACLE_HOME}/OPatch/opatch lsinventory -all|grep "Oracle Database"
echo "==============================="
esac # End case $LINE
done
# End Loop read ORATAB

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.