1826103 Members
4802 Online
109690 Solutions
New Discussion

cmviewcl output query

 
Sajith Abeyanayake
Occasional Contributor

cmviewcl output query

To automatically establish the status of a MCSG package, I need to parse the output of cmviewcl(1). The bit that gives the package status looks like (for example):

PACKAGE STATUS STATE AUTO_RUN NODE
DES_DATABASE up running enabled kpux01

Now in order to reliably parse this, the fields would have to be whitespace separated (i.e. at least one blank &/or tab). If cmviewcl guarantees whitespace separation, then if the package name in this example was one character longer, we'd see something like this:

PACKAGE STATUS STATE AUTO_RUN NODE
DES_DATABASE1 up running enabled kpux01

If on the other hand, cmviewcl just uses fixed-length fields then we would see something like:

PACKAGE STATUS STATE AUTO_RUN NODE
DES_DATABASE1up running enabled kpux01

which is of course difficult to parse (or outright impossible if the package name was another character longer again, e.g. DES_DATABASE12).

This more in the nature of an inquiry rather than a problem.

Any suggestion welcome
7 REPLIES 7
Sajith Abeyanayake
Occasional Contributor

Re: cmviewcl output query

cmviewcl adjusts fieldwidths if the name would otherwise overflow it.

Sajith

Carsten Krege
Honored Contributor

Re: cmviewcl output query

cmviewcl always guarantees at least one space character between package name and package status.

There is an enhancement request pending (SR8606217344) that requests a new option for cmviewcl to provide machine readable output, but so far the Serviceguard lab has not worked on this.

Carsten
-------------------------------------------------------------------------------------------------
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move. -- HhGttG
Geoff Wild
Honored Contributor

Re: cmviewcl output query

As far as I know - there is always a space...

On all my clusters there is.

As far as parsing, why not just
cmviewcl |grep up
or
cmviewcl |grep package

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Sanjay_6
Honored Contributor

Re: cmviewcl output query

Hi,

The cmcviewcl output is not a fixed length output. There is always a blank space in between words.

Hope this helps.

Regds
RAC_1
Honored Contributor

Re: cmviewcl output query

I always use
cmviewcl -p pkg1 -v
cmviewcl -p pkg2 -v

Anil
There is no substitute to HARDWORK
Stephen Doud
Honored Contributor

Re: cmviewcl output query

# cat chkstat
PKG=ignite
STATUS=`cmviewcl | grep $PKG | awk {'print $2'}`
echo $STATUS

# ./chkstat
up

-StephenD.
Kent Ostby
Honored Contributor

Re: cmviewcl output query

As Stephen's example demonstrates, you can find fields easily in awk.

I would suggest looking into that for your needs since you could easily pipe the output you are looking for such as:

cmviewcl -v | grep ^PACKAGE | awk '{whatever}'

Best regards,

Kent M. Ostby
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"