#!/bin/bash # [crsstat -t] # Source: http://www.dbspecialists.com/specialists/specialist2007-05.html # Requirements: # - $ORA_CRS_HOME should be set in your environment if [ "x$ORA_CRS_HOME" == "x" ]; then ORA_CRS_HOME=/export/home/oracle/product/10.2.0/crs fi RSC_KEY=$1 QSTAT=-u AWK=/usr/xpg4/bin/awk $AWK \ 'BEGIN {printf "%-45s %-10s %-18s\n", "HA Resource", "Target", "State"; printf "%-45s %-10s %-18s\n", "-----------", "------", "-----";}' $ORA_CRS_HOME/bin/crs_stat $QSTAT | $AWK \ 'BEGIN { FS="="; state = 0; } $1~/NAME/ && $2~/'$RSC_KEY'/ {appname = $2; state=1}; state == 0 {next;} $1~/TARGET/ && state == 1 {apptarget = $2; state=2;} $1~/STATE/ && state == 2 {appstate = $2; state=3;} state == 3 {printf "%-45s %-10s %-18s\n", appname, apptarget, appstate; state=0;}'