#!/bin/ksh
if [ `uname` = Linux ] ; then
ORATAB=/etc/oratab
export ORATAB
elif [ `uname` = Sunos ] ; then
ORATAB=/var/opt/oracle/oratab
export ORATAB
fi
printf '\e[1;34m\t%-25s %-25s %-25s %-25s\n\e[m' "Database Name" "Mode" "Role" "Unique Name"
for i in `ps -ef|grep pmon|awk '{print $8}'|cut -d_ -f3|grep -v grep|grep -v +ASM*|grep -v "\-MGMTDB"`
do
export ORACLE_SID=$i
export ORACLE_HOME=`cat $ORATAB|grep $i|cut -d: -f2`
export PATH=$ORACLE_HOME/bin:$PATH:
export DNAME=`sqlplus -s / as sysdba <<END
set pagesize 0 feedback off verify off heading off echo off
select name from v\\$database;
exit;
END`
export MODE=`sqlplus -s / as sysdba <<END
set pagesize 0 feedback off verify off heading off echo off
select open_mode from v\\$database;
exit;
END`
export ROLE=`sqlplus -s / as sysdba <<END
set pagesize 0 feedback off verify off heading off echo off
select database_role from v\\$database;
exit;
END`
export UNIQUE=`sqlplus -s / as sysdba <<END
set pagesize 0 feedback off verify off heading off echo off
select value from v\\$parameter where name='db_unique_name';
exit;
END`
printf '\e[1;32m\t%-25s %-25s %-25s %-25s\n\e[m' "${DNAME}" "${MODE}" "${ROLE}" "${UNIQUE}"
done
if [ `uname` = Linux ] ; then
ORATAB=/etc/oratab
export ORATAB
elif [ `uname` = Sunos ] ; then
ORATAB=/var/opt/oracle/oratab
export ORATAB
fi
printf '\e[1;34m\t%-25s %-25s %-25s %-25s\n\e[m' "Database Name" "Mode" "Role" "Unique Name"
for i in `ps -ef|grep pmon|awk '{print $8}'|cut -d_ -f3|grep -v grep|grep -v +ASM*|grep -v "\-MGMTDB"`
do
export ORACLE_SID=$i
export ORACLE_HOME=`cat $ORATAB|grep $i|cut -d: -f2`
export PATH=$ORACLE_HOME/bin:$PATH:
export DNAME=`sqlplus -s / as sysdba <<END
set pagesize 0 feedback off verify off heading off echo off
select name from v\\$database;
exit;
END`
export MODE=`sqlplus -s / as sysdba <<END
set pagesize 0 feedback off verify off heading off echo off
select open_mode from v\\$database;
exit;
END`
export ROLE=`sqlplus -s / as sysdba <<END
set pagesize 0 feedback off verify off heading off echo off
select database_role from v\\$database;
exit;
END`
export UNIQUE=`sqlplus -s / as sysdba <<END
set pagesize 0 feedback off verify off heading off echo off
select value from v\\$parameter where name='db_unique_name';
exit;
END`
printf '\e[1;32m\t%-25s %-25s %-25s %-25s\n\e[m' "${DNAME}" "${MODE}" "${ROLE}" "${UNIQUE}"
done