java to quickly list rac dbs or check if a db is in the rac db list
import oracle.ops.mgmt.operation.ListParallelServersOperation;
import oracle.ops.mgmt.operation.ListParallelServersResult;
public class ClusterCheck {
private static final String USAGE = " no args lists all cluster dbs\n 1 arg checks to see if that db is clustered";
public static void main(String[] args) {
if (args.length > 1) {
System.err.println("too many arguments");
System.err.println(USAGE);
System.exit(1);
} else if (args.length == 1
&& (args[0].equals("-h") || args[0].equals("-?"))) {
System.err.println("'"+args[0]+"' : help");
System.out.println(USAGE);
System.exit(0);
} else if (args.length == 1
&& args[0].startsWith("-")) {
System.err.println("argument '"+args[0]+"' not understood");
System.err.println(USAGE);
System.exit(1);
}
ListParallelServersOperation lpso = new ListParallelServersOperation();
ListParallelServersResult lpsr = (ListParallelServersResult)lpso.run();
String [] result = lpsr.getResult();
if (args.length == 0) {
for (int i = 0; i<result.length; i++) {
System.out.println(result[i]);
}
} else {
for (int i = 0; i<result.length; i++) {
if (result[i].toLowerCase().equals(args[0].toLowerCase())) {
System.out.println(result[i] + " is clustered");
System.exit(0);
}
}
System.out.println(args[0] + " is not clustered");
System.exit(1);
}
System.exit(0);
}
}
plus shell script to run it
#!/bin/sh
ScriptsDir=/var/opt/oracle/admin/scripts
case $ORACLE_HOME in
"") echo "****ORACLE_HOME environment variable not set!"
echo "Â Â Â ORACLE_HOME should be set to the main"
echo "Â Â Â directory that contains Oracle products."
echo "Â Â Â Set and export ORACLE_HOME, then re-run."
exit 1;;
esac
# External Directory Variables set by the Installer
JREDIR=$ORACLE_HOME/JRE
JLIBDIR=$ORACLE_HOME/jlib
# jar files
SRVMJAR=$JLIBDIR/srvm.jar
SRVCTLJAR=$ORACLE_HOME/srvm/jlib/srvctl.jar
#NetCa config jar
NETCFGJAR=$JLIBDIR/netcfg.jar
# JRE Executable and Class File Variables
JRE=$JREDIR/bin/jre
JRECLASSES=$JREDIR/lib/classes.zip
JREJAR=$JREDIR/lib/rt.jar
CLASSPATH=$ScriptsDir:$NETCFGJAR:$JREJAR:$SRVMJAR:$SRVCTLJAR
# Set the shared library path for JNI shared libraries
# A few platforms use an environment variable other than LD_LIBRARY_PATH
SET_DEFAULT=YES
PLATFORM=`uname`
case $PLATFORM in "HP-UX"|"HI-UX")
SET_DEFAULT=NO
SHLIB_PATH=$ORACLE_HOME/lib32:$ORACLE_HOME/srvm/lib:$SHLIB_PATH
export SHLIB_PATH
esac
case $SET_DEFAULT in "YES")
LD_LIBRARY_PATH=$ORACLE_HOME/lib32:$ORACLE_HOME/srvm/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
esac
java -classpath $CLASSPATH ClusterCheck "$@"
exit $?