Use API QWCRSSts to retrieve system status information

This tip shows you how to use API QWCRSSts to retrieve system status information.

This tip shows you how to use API QWCRSSts to retrieve system status information, such as that found on the WrkSysSts (Work with System Status) panel. Program RtvSysStsC demonstrates API usage in CL programs by using API QWCRSSts to retrieve the following information:

* System ASP -- storage capacity of the system auxiliary storage pool (ASP 1).
* % System ASP used -- percentage (in ten-thousandths) of the system auxiliary storage pool currently in use.
* Total auxiliary storage -- total auxiliary storage (in millions of bytes) on the system.
* Current unprotected storage used -- current amount of storage (in millions of bytes) in use for temporary objects.
* Maximum unprotected storage used -- largest amount of storage (in millions of bytes) of storage for temporary objects used at any one time since the last IPL.

RtvSysStsC performs the following basic steps:

1. Initialize program variables.
2. Retrieve system status information with API QWCRSSts.
3. Check for and percolate any errors returned by API.
4. Extract system status information from variable returned by the API.

The source shows that you insert code specific to your needs after extracting the system status information.


 		
/*  ===============================================================  */
/*  = Program....... RtvSysStsC                                   =  */
/*  = Description... Retrieve system status information           =  */
/*  ===============================================================  */

Pgm

/*  ===============================================================  */
/*  = Declarations                                                =  */
/*  ===============================================================  */

  Dcl        &RcvVar     *Char     (   68    )
  Dcl        &RcvVarLen  *Char     (    4    )
  Dcl        &Format     *Char     (    8    )
  Dcl        &Reset      *Char     (   10    )
  Dcl        &Bin4Nbr    *Char     (    4    )
  Dcl        &Dec15Nbr   *Dec      (   15  0 )
  Dcl        &SysASP     *Dec      (   15  0 )
  Dcl        &SysASPUsed *Dec      (   15  4 )
  Dcl        &TotAuxStg  *Dec      (   15  0 )
  Dcl        &CurUnpUsed *Dec      (   15  0 )
  Dcl        &MaxUnpUsed *Dec      (   15  0 )
  Dcl        &APIError   *Char     (  272    )
  Dcl        &BytesProv  *Char     (    4    )
  Dcl        &BytesAvail *Char     (    4    )
  Dcl        &MsgID      *Char     (    7    )
  Dcl        &MsgDta     *Char     (  256    )
  Dcl        &MsgF       *Char     (   10    )
  Dcl        &MsgFLib    *Char     (   10    )

/*  ===============================================================  */
/*  = Global error monitor                                        =  */
/*  ===============================================================  */

  MonMsg     ( CPF0000 MCH0000 ) Exec(                                +
    GoTo       Error                 )

/*  ===============================================================  */
/*  = Initialize variables                                        =  */
/*  ===============================================================  */

  ChgVar      &Format  ( 'SSTS0200' )
  ChgVar      &Reset   ( '*YES' )

  ChgVar      ( %Bin( &RcvVarLen ) )     ( 68 )
  ChgVar      ( %Bin( &BytesProv ) )     ( 272 )
  ChgVar      ( %Bin( &BytesAvail ) )    ( 0 )
  ChgVar      ( %Sst( &APIError 1 4 ) )  ( &BytesProv )
  ChgVar      ( %Sst( &APIError 5 4 ) )  ( &BytesAvail )

/*  ===============================================================  */
/*  = Retrieve system status information                          =  */
/*  ===============================================================  */

  Call       QWCRSSts                                                 +
                      (                                               +
                        &RcvVar                                       +
                        &RcvVarLen                                    +
                        &Format                                       +
                        &Reset                                        +
                        &APIError                                     +
                      )

/*  ---------------------------------------------------------------  */
/*  - Check for error and percolate if one exists                 -  */
/*  ---------------------------------------------------------------  */

  ChgVar      &BytesAvail  ( %Sst( &APIError 5 4 ) )

  If         ( %Bin( &BytesAvail ) *NE 0 )                            +
    Do
      ChgVar      &MsgID    ( %Sst( &APIError  9   7 ) )
      ChgVar      &MsgDta   ( %Sst( &APIError 17 256 ) )
      ChgVar      &MsgF     ( 'QCPFMSG' )
      ChgVar      &MsgFLib  ( 'QSYS' )
      GoTo        SndMsg
    EndDo

/*  ===============================================================  */
/*  = Extract system status information                           =  */
/*  ===============================================================  */

  ChgVar      &Bin4Nbr     ( %Sst( &RcvVar 49 4 ) )
  ChgVar      &SysASP      ( %Bin( &Bin4Nbr ) )

  ChgVar      &Bin4Nbr     ( %Sst( &RcvVar 53 4 ) )
  ChgVar      &Dec15Nbr    ( %Bin( &Bin4Nbr ) )
  ChgVar      &SysASPUsed  ( &Dec15Nbr / 10000 )

  ChgVar      &Bin4Nbr     ( %Sst( &RcvVar 57 4 ) )
  ChgVar      &TotAuxStg   ( %Bin( &Bin4Nbr ) )

  ChgVar      &Bin4Nbr     ( %Sst( &RcvVar 61 4 ) )
  ChgVar      &CurUnpUsed  ( %Bin( &Bin4Nbr ) )

  ChgVar      &Bin4Nbr     ( %Sst( &RcvVar 65 4 ) )
  ChgVar      &MaxUnpUsed  ( %Bin( &Bin4Nbr ) )

/*  ===============================================================  */
/*  = Insert your code that uses the system status values         =  */
/*  ===============================================================  */

/*  ===============================================================  */
/*  = Exit program                                                =  */
/*  ===============================================================  */

  Return

/*  ===============================================================  */
/*  = Error routine                                               =  */
/*  ===============================================================  */

Error:

  RcvMsg     MsgType( *Excp )                                         +
             MsgDta( &MsgDta )                                        +
             MsgID( &MsgID )                                          +
             MsgF( &MsgF )                                            +
             MsgFLib( &MsgFLib )

  MonMsg     ( CPF0000 MCH0000 )

SndMsg:

  SndPgmMsg  MsgID( &MsgID )                                          +
             MsgF( &MsgFLib/&MsgF )                                   +
             MsgDta( &MsgDta )                                        +
             MsgType( *Escape )

  MonMsg     ( CPF0000 MCH0000 )

/*  ===============================================================  */
/*  =  End of program                                             =  */
/*  ===============================================================  */

EndPgm  

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your systems management questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our systems management gurus are waiting to answer your technical questions.

This was first published in November 2001

Dig deeper on Performance

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchEnterpriseLinux

SearchDataCenter

Close