from web ... cat crsctl1.sh #!/bin/bash # # 11g CRS resource status query script # # Description: # - Returns formatted version of crs_stat -t, in tabular # format, with the complete rsc names and filtering keywords # - The argument, $RSC_KEY, is optional and if passed to the script, will # limit the output to HA resources whose names match $RSC_KEY. # Requirements: # - $ORA_CRS_HOME should be set in your environment RSC_KEY=$1 QSTAT=-u AWK=/bin/awk # if not available use /usr/bin/awk # Table header:echo "" $AWK \ 'BEGIN {printf "%-45s %-10s %-18s\n", "HA Resource", "Target", "State"; printf "%-45s %-10s %-18s\n", "-----------", "------", "-----";}' # Table body: crsctl status resource | $AWK \ ' function ltrim(s) { sub(/^[ \t]+/, "", s); return s } function rtrim(s) { sub(/[ \t]+$/, "", s); return s } function trim(s) { return rtrim(ltrim(s)); } BEGIN { FS="="; state = 0; } $1~/NAME/ && $2~/'$RSC_KEY'/ {appname = $2; state=1}; state == 0 {next;} $1~/TARGET/ && state == 1 {apptarget = $2; split(apptarget, atarget, ","); state=2;} $1~/STATE/ && state == 2 {appstate = $2; split(appstate, astate, ","); state=3;} state == 3 { split(appname, a, ","); for (i = 1; i <= length(atarget); i++) { printf "%-45s %-10s %-18s\n", appname, trim(atarget[i]), trim(astate[i]) }; state=0;}' chmod 700 crsctl1.sh ============ HA Resource Target State ----------- ------ ----- ora.DATA.dg ONLINE ONLINE on oragrid ora.LISTENER.lsnr ONLINE ONLINE on oragrid ora.asm ONLINE ONLINE on oragrid ora.cssd ONLINE ONLINE on oragrid ora.diskmon OFFLINE OFFLINE ora.evmd ONLINE ONLINE on oragrid ora.ons OFFLINE OFFLINE
Search This Blog
Total Pageviews
Thursday, 12 December 2024
crsctl status resource script
Subscribe to:
Post Comments (Atom)
Oracle DBA
anuj blog Archive
- ► 2011 (362)
No comments:
Post a Comment