Wednesday, March 23, 2011

Formatted CRS_STAT output

Here is the important information for Crs_stat output from my oracle tutor.


At Many time we require to see all the content of CRS Resources, unfortunately resource information are adjusted in the width
provided for crsctl.

Create this script in $ORA_CRS_HOME/bin/crs_stat_new

#!/usr/bin/ksh
export `which crs_stat|xargs cat |grep ORA_CRS_HOME=`
RSC_KEY=$1
QSTAT=-u
AWK=/usr/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;}'
Execute it on any of the Nodes.

chmod 755 $ORA_CRS_HOME/bin/crs_stat_new

See the change in output..