Oracle : Generate Clear output for crs_stat -t
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
cat crsstat.sh #!/bin/bash RSC_KEY=$1 QSTAT=-u AWK=/bin/awk # if not available use /usr/bin/awk # Table header:echo "" $AWK \ 'BEGIN {printf "%-55s %-10s %-18s\n", "HA Resource", "Target", "State"; printf "%-55s %-10s %-18s\n", "-----------", "------", "-----";}' # Table body: ORA_CRS_HOME=/u01/app/grid/product/12102 $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 "%-55s %-10s %-18s\n", appname, apptarget, appstate; state=0;}' |
chmod 755 crsstat.sh
Output :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
./crsstat.sh HA Resource Target State ----------- ------ ----- ora.CRS01.dg ONLINE ONLINE on server11 ora.DATA01.dg ONLINE ONLINE on server11 ora.FRA01.dg ONLINE ONLINE on server11 ora.LISTENER.lsnr ONLINE ONLINE on server11 ora.LISTENER_SCAN1.lsnr ONLINE ONLINE on server12 ora.LISTENER_SCAN2.lsnr ONLINE ONLINE on server11 ora.LISTENER_SCAN3.lsnr ONLINE ONLINE on server11 ora.MGMTLSNR ONLINE ONLINE on server11 ora.REDO01.dg ONLINE ONLINE on server11 ora.REDO02.dg ONLINE ONLINE on server11 ora.asm ONLINE ONLINE on server11 ora.cvu ONLINE ONLINE on server11 ora.mgmtdb ONLINE ONLINE on server11 ora.net1.network ONLINE ONLINE on server11 ora.oc4j ONLINE ONLINE on server11 ora.ons ONLINE ONLINE on server11 ora.orcl2.vin_svc_node1.svc ONLINE ONLINE on server11 ora.orcl2.vin_svc_node2.svc ONLINE ONLINE on server11 ora.scan1.vip ONLINE ONLINE on server12 ora.scan2.vip ONLINE ONLINE on server11 ora.scan3.vip ONLINE ONLINE on server11 ora.server11.ASM1.asm ONLINE ONLINE on server11 ora.server11.LISTENER_server11.lsnr ONLINE ONLINE on server11 ora.server11.ons ONLINE ONLINE on server11 ora.server11.vip ONLINE ONLINE on server11 ora.server12.ASM2.asm ONLINE ONLINE on server12 ora.server12.LISTENER_server12.lsnr ONLINE ONLINE on server12 ora.server12.ons ONLINE ONLINE on server12 ora.server12.vip ONLINE ONLINE on server12 |
Note: Please test scripts in Non Prod before trying in Production.