在10g RAC中我们常用crs_stat命令查看CRS资源的状态,但是crs_stat命令的输出并不完整。可以通过以下脚本来优化crs_stat的输出:
--------------------------- Begin Shell Script -------------------------------
#!/usr/bin/ksh
#
# Sample 10g 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=/usr/xpg4/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:
$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;}'
--------------------------- End Shell Script -------------------------------
© 2011, www.oracledatabase12g.com. 版权所有.文章允许转载,但必须以链接方式注明源地址,否则追究法律责任.
相关文章 | Related posts:
- Backup Script:Expdp Schema to ASM Storage
- Script to Identify Objects and Amount of Blocks in the Buffer Pools – Default, Keep, Recycle, nK Cache
- 在linux平台上如何修改hostid
- Oracle Systemstate dump analytic tool: ASS.AWK V1.09
- rac中手动关闭的Listener资源会自动重启?
- Script to Prevent Excessive Spill of Message From the Streams Buffer Queue To Disk
- ORA-4030 PGA Usage Diagnostic Script
- 使用Oracle RMAN脚本
- Script to Detect Tablespace Fragmentation
- Script:Monitoring Memory and Swap Usage to Avoid A Solaris Hang




The perfect output is shown at following:
[root@dbu1pub~]# $CRS_HOME/bin/crs_stat -t
Name Type Target State Host
————————————————————
ora….UB.lsnr application ONLINE ONLINE dbu1pub
ora….pub.gsd application ONLINE ONLINE dbu1pub
ora….pub.ons application ONLINE ONLINE dbu1pub
ora….pub.vip application ONLINE ONLINE dbu1pub
ora….UB.lsnr application ONLINE ONLINE dbu2pub
ora….pub.gsd application ONLINE ONLINE dbu2pub
ora….pub.ons application ONLINE ONLINE dbu2pub
ora….pub.vip application ONLINE ONLINE dbu2pub
ora.ssp.db application ONLINE ONLINE dbu1pub
ora….p1.inst application ONLINE ONLINE dbu1pub
ora….p2.inst application ONLINE ONLINE dbu2pub