Script:优化crs_stat命令的输出

作者: Maclean Liu , post on August 29th, 2011 , English Version
【本站文章除注明转载外,均为本站原创编译】
转载请注明:文章转载自: Oracle Clinic – Maclean Liu的个人技术博客 [http://www.oracledatabase12g.com/]
本文标题: Script:优化crs_stat命令的输出
本文永久地址: http://www.oracledatabase12g.com/archives/script%e4%bc%98%e5%8c%96crs_stat%e5%91%bd%e4%bb%a4%e7%9a%84%e8%be%93%e5%87%ba.html

在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:

  1. Backup Script:Expdp Schema to ASM Storage
  2. Script to Identify Objects and Amount of Blocks in the Buffer Pools – Default, Keep, Recycle, nK Cache
  3. 在linux平台上如何修改hostid
  4. Oracle Systemstate dump analytic tool: ASS.AWK V1.09
  5. rac中手动关闭的Listener资源会自动重启?
  6. Script to Prevent Excessive Spill of Message From the Streams Buffer Queue To Disk
  7. ORA-4030 PGA Usage Diagnostic Script
  8. 使用Oracle RMAN脚本
  9. Script to Detect Tablespace Fragmentation
  10. Script:Monitoring Memory and Swap Usage to Avoid A Solaris Hang

1 comment to Script:优化crs_stat命令的输出

  • chengwill

    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

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>