Re: crs_stat formatting questions and comments

From: louis liu <ylouis83_at_gmail.com>
Date: Tue, 10 Jul 2012 09:54:40 +0800
Message-ID: <CAARjh8m77mC1r1wH4bAiMocBJKRvzh0A6db=YkTHVRcauaxKqw_at_mail.gmail.com>



try this scripts :

[oracle_at_db-35 tools]$ cat crstat
#!/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=/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;}'

eg:

[oracle_at_db-35 tools]$ crstat

HA Resource                                   Target     State
-----------                                   ------     -----
ora.db-35.ASM1.asm                            ONLINE     ONLINE on db-35
ora.db-35.LISTENER_DB-35.lsnr                 ONLINE     ONLINE on db-35
ora.db-35.gsd                                 ONLINE     ONLINE on db-35
ora.db-35.ons                                 ONLINE     ONLINE on db-35
ora.db-35.vip                                 ONLINE     ONLINE on db-35
ora.db-36.ASM2.asm                            ONLINE     ONLINE on db-36
ora.db-36.LISTENER_DB-36.lsnr                 ONLINE     ONLINE on db-36
ora.db-36.gsd                                 ONLINE     ONLINE on db-36
ora.db-36.ons                                 ONLINE     ONLINE on db-36
ora.db-36.vip                                 ONLINE     ONLINE on db-36
ora.item.db                                   ONLINE     ONLINE on db-35
ora.item.item1.inst                           ONLINE     ONLINE on db-35
ora.item.item2.inst                           ONLINE     ONLINE on db-36

2012/7/9 Taylor, Chris David <ChrisDavid.Taylor_at_ingrambarge.com>

> So, why does "crs_stat -t" formatting not adjust correctly to my terminal
> size?
> (I'm using the default gnome-terminal in Oracle Linux so any suggestions
> along that line are also appreciated)
>


> $ crs_stat -t
>
> Name           Type           Target    State     Host
> ------------------------------------------------------------
> ora.GRID.dg    ora....up.type ONLINE    ONLINE    rac1
> ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac1
> ora....N1.lsnr ora....er.type ONLINE    ONLINE    rac2
> ora....N2.lsnr ora....er.type ONLINE    ONLINE    rac1
> ora....N3.lsnr ora....er.type ONLINE    ONLINE    rac1
> ora.asm        ora.asm.type   ONLINE    ONLINE    rac1
> ora.cvu        ora.cvu.type   ONLINE    ONLINE    rac1
> ora.gsd        ora.gsd.type   OFFLINE   OFFLINE
> ora....network ora....rk.type ONLINE    ONLINE    rac1
> ..
> ..
>
> I downloaded
> http://blog.enkitec.com/wp-content/uploads/2012/04/crsstat.v1.2.1.zipwritten by Paul Elbow _at_ Enkitec but it seems (to me) that I should be able
> to set up my default user profile so that crs_stat -t always displays
> correctly but perhaps I'm mistaken.
>
> I don't understand why crs_stat is formatting so badly.
>
> Chris Taylor
>
> "Quality is never an accident; it is always the result of intelligent
> effort."
> -- John Ruskin (English Writer 1819-1900)
>
> Any views and/or opinions expressed herein are my own and do not
> necessarily reflect the views of Ingram Industries, its affiliates, its
> subsidiaries or its employees.
>
>
>
>
> --
> http://www.freelists.org/webpage/oracle-l
>

>
>
-- 
Phone: +86 13918046970
Email & Gtalk:  ylouis83_at_gmail.com
Personal Blog: http://www.vmcd.org


--
http://www.freelists.org/webpage/oracle-l
Received on Mon Jul 09 2012 - 20:54:40 CDT

Original text of this message