system information into a file

1150 pts.
Tags:
CL programming
Disk storage
How can I retrieve system CPU,Memory,disk usage on AS/400 into a file?

Answer Wiki

Thanks. We'll let you know when a new response is added.

It seems that the answer is to call the <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp”>Retrieve System Status (QWCRSSTS) API</a> with format SSTS0200, or perhaps SSTS0300, and extract needed data from the data structure that is returned from the API.

Use whatever method is best for you to write the data to a file.

Tom

Discuss This Question: 7  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    I run a basic process once a week to capture that kind of information. I insert it into a file so that I have a running trend that goes back almost ten years on one of our servers. Here's a straight text copy/paste from RUNQRY showing the latest few weeks of data:
                                                              Display Report                                                            
                                                                                                      Report width . . . . . :     121  
     Position to line  . . . . .                                                                  Shift to column  . . . . . .          
     Line   ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10....+...11....+...12.   
            DATTIM            ELPHH  ELPMM  ELPSS   CPUPCT   JOBCNT   PADPCT   TADPCT   ASPSIZ     ASPPCT   TOTAUX   CURUNP   MAXUNP    
     000491 1100110230001614     0      0      1        .0    1,350     .010     .105   70,330    85.9302   70,330    2,222    2,333    
     000492 1100117230001722     0      0      1        .0    1,376     .010     .105   70,330    86.3269   70,330    2,223    2,336    
     000493 1100124230001652     0      0      1        .0    1,411     .010     .105   70,330    87.0759   70,330    2,210    2,323    
     000494 1100131230001637     0      0      1        .4    1,419     .010     .105   70,330    87.8565   70,330    2,214    2,325    
     000495 1100207230001601     0      0      1        .0    1,389     .010     .105   70,330    79.8492   70,330    2,213    2,327    
     000496 1100214230001691     0      0      1        .4    1,377     .010     .105   70,330    80.6243   70,330    2,214    2,326    
     000497 1100221230001674     0      0      1        .4    1,526     .010     .105   70,330    82.8789   70,330    3,862    3,976    
     000498 1100228230001651     0      0      1        .0    1,601     .010     .105   70,330    81.5193   70,330    2,221    2,335    
     000499 1100307230001644     0      0      1        .0    1,505     .010     .105   70,330    82.0721   70,330    2,233    2,347    
     000500 1100314230001764     0      0      1        .0    1,432     .010     .105   70,330    82.8083   70,330    2,227    2,333    
     000501 1100321230001555     0      0      1        .0    1,455     .010     .105   70,330    83.5701   70,330    2,217    2,331    
     000502 1100328230001601     0      0      1        .0    1,479     .010     .105   70,330    76.2906   70,330    2,216    2,328    
     000503 1100404230001626     0      0      1        .0    1,478     .010     .108   70,330    77.0663   70,330    2,222    2,335    
     000504 1100411230001671     0      0      1        .4    1,612     .010     .108   70,330    78.3218   70,330    2,753    2,765    
     000505 1100418230001660     0      0      1        .0    1,625     .010     .108   70,330    79.9277   70,330    3,855    3,969    
     000506 1100425230001691     0      0      1        .4    1,476     .010     .108   70,330    77.2412   70,330      761      872    
     000507 1100502230001604     0      0      1        .0    1,810     .010     .108   70,330    81.3509   70,330    3,857    3,971    
     000508 1100509230001632     0      0      1        .4    1,810     .010     .108   70,330    78.5132   70,330    2,215    2,328    
     ****** ********  End of report  ********                                                                                           
                                                                                                                               Bottom   
     F3=Exit      F12=Cancel      F19=Left      F20=Right      F21=Split      F22=Width 80
    Is that the kind of data you're looking for? Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    ...Because if that's what you need, I can supply a fairly straightforward way to get it. But if it isn't, then we need a little more explanation. Tom
    125,585 pointsBadges:
    report
  • carlosdl
    You are going to post the code anyway, aren't you ? Some code doesn't hurt anybody, and it could help other people looking for that information in the future... :-) ;)
    68,430 pointsBadges:
    report
  • TomLiotta
    Well, I can post the code that I use. It's from some 15 years ago (though it's been updated for some V5R3 CL changes), so I'd do it a little differently today. In RPG, it could be shorter; but CL can be easier to learn what many basic APIs do. If this doesn't do what's needed, I'd rather post more appropriate code. That's especially true because of what happens at the end of this:
    pgm
    
    /* The API parms...                                                 */
    /*   For Retrieve System Status...                                  */
       dcl   &Sts_Data    *char   68
       dcl   &Sts_Len     *int          value( 68 )
       dcl   &Sts_Format  *char    8    value( 'SSTS0200' )
       dcl   &Reset_Ind   *char   10    value( '*NO' )
    
    /*   For Convert Date & Time...                                     */
       dcl   &CDT_I_Form  *char   10    value( '*DTS' )
       dcl   &CDT_I_Var   *char    8
       dcl   &CDT_O_Form  *char   10    value( '*YMD' )
       dcl   &CDT_O_Var   *char   16
    
    /* And we'll need to specify an errcode receiver at one point...    */
       dcl   &errcode     *char  116    value( x'00000074')
       dcl   &errlen      *int          value( 0 ) /* +
                    Will tell us how long any exception data +
                    is... */
    
    /* These are *char versions of the *dec vars...                     */
       dcl   &ElpHH_C     *char    2
       dcl   &ElpMM_C     *char    2
       dcl   &ElpSS_C     *char    2
       dcl   &CPUPct_C    *char    8
       dcl   &JobCnt_C    *char    6
       dcl   &PADPct_C    *char    7
       dcl   &TADPct_C    *char    7
       dcl   &ASPSiz_C    *char    9
       dcl   &ASPPct_C    *char    8
       dcl   &TotAux_C    *char    9
       dcl   &CurUnp_C    *char    6
       dcl   &MaxUnp_C    *char    6
    
    /* The SQL statement gets built from *CATted values...              */
       dcl   &SQL_Stmt    *char  256
    
    
       dclf  SYSYSSTSPF
    
    
       call   Qsys/QWCRSSTS     ( +
                                  &Sts_Data    +
                                  &Sts_Len     +
                                  &Sts_Format  +
                                  &Reset_Ind   +
                                  &errcode     +
                                )
    
       chgvar      &CDT_I_Var         %sst( &Sts_Data 9 8 )
    
       call   Qsys/QWCCVTDT     ( +
                                  &CDT_I_Form  +
                                  &CDT_I_Var   +
                                  &CDT_O_Form  +
                                  &CDT_O_Var   +
                                  &errcode     +
                                )
    /* Test for an exception...                                         */
       chgvar      &errlen            %bin( &errcode 5 4 )
    
    /* Test for any error...                                            */
       if ( &errlen *gt 0 )  do
          sndpgmmsg  msgid( CPF9898 )  msgf( QCPFMSG ) +
                       msgdta( +
                               %sst( &errcode 9 7 ) *bcat +
                               'error exception' +
                             ) +
                       msgtype( *ESCAPE )
       enddo
    
    
       chgvar      &DATTIM                  &CDT_O_Var
    
       chgvar      &ElpHH_C           %sst( &Sts_Data 25 2 )
       chgvar      &ElpMM_C           %sst( &Sts_Data 27 2 )
       chgvar      &ElpSS_C           %sst( &Sts_Data 29 2 )
       chgvar      &CPUPCT          ( %bin( &Sts_Data 33 4 ) * 0.1 )
       chgvar      &CPUPct_C                &CPUPCT
       chgvar      &JOBCNT            %bin( &Sts_Data 37 4 )
       chgvar      &JobCnt_C                &JOBCNT
       chgvar      &PADPCT          ( %bin( &Sts_Data 41 4 ) * 0.001 )
       chgvar      &PADPct_C                &PADPCT
       chgvar      &TADPCT          ( %bin( &Sts_Data 45 4 ) * 0.001 )
       chgvar      &TADPct_C                &TADPCT
       chgvar      &ASPSIZ            %bin( &Sts_Data 49 4 )
       chgvar      &ASPSiz_C                &ASPSIZ
       chgvar      &ASPPCT          ( %bin( &Sts_Data 53 4 ) * 0.0001 )
       chgvar      &ASPPct_C                &ASPPCT
       chgvar      &TOTAUX            %bin( &Sts_Data 57 4 )
       chgvar      &TotAux_C                &TOTAUX
       chgvar      &CURUNP            %bin( &Sts_Data 61 4 )
       chgvar      &CurUnp_C                &CURUNP
       chgvar      &MAXUNP            %bin( &Sts_Data 65 4 )
       chgvar      &MaxUnp_C                &MAXUNP
    
    /* All values have been extracted from the API and converted to +
       *char. (The conversion allows the *CATs in RUNSQL below...)     */
    
       chgvar      &SQL_Stmt          ( 'insert into SYSYSSTSPF +
                    values (''' *cat &DATTIM *tcat ''',' +
                    *bcat &ElpHH_C *tcat ',' *bcat &ElpMM_C +
                    *tcat ',' *bcat &ElpSS_C *tcat ',' *bcat +
                    &CPUPct_C *tcat ',' *bcat &JobCnt_C *tcat +
                    ',' *bcat &PADPct_C *tcat ',' *bcat +
                    &TADPct_C *tcat ',' *bcat &ASPSiz_C *tcat +
                    ',' *bcat &ASPPct_C *tcat ',' *bcat +
                    &TotAux_C *tcat ',' *bcat &CurUnp_C *tcat +
                    ',' *bcat &MaxUnp_C *tcat ')')
    
    
       RRUNSQL    SQL( &SQL_Stmt )
    
       return
    
    endpgm
    The RRUNSQL command executes the constructed SQL INSERT statement. RRUNSQL is my own version of a concept that's been around for almost 20 years. I wrote mine way back then and haven't had a need to change it. However, it's really not a good example of a generic SQL processor because I wrote it as an exercise in REXX rather than anything else. I'd suggest creating a basic QM query that does the INSERT and passing the variables directly into that, rather than constructing SQL on the fly. Or even better, just calling the QWCCVTDT API and using WRITE to write the record. My output file is simply:
         A          R SYSYSSTSRF
         A            DATTIM        16   B      TEXT('Date/time 0YYMMDDHHMMSSMMM')
         A            ELPHH          2S 0B      TEXT('Elapsed time hours')
         A            ELPMM          2S 0B      TEXT('Elapsed time minutes')
         A            ELPSS          2S 0B      TEXT('Elapsed time seconds')
         A            CPUPCT         5P 1B      TEXT('% CPU Used *bin(4)')
         A            JOBCNT         5P 0B      TEXT('Jobs in system *bin(4)')
         A            PADPCT         5P 3B      TEXT('% Perm Addrs used *bin(4)')
         A            TADPCT         5P 3B      TEXT('% Temp Addrs used *bin(4)')
         A            ASPSIZ         5P 0B      TEXT('System ASP size *bin(4)')
         A            ASPPCT         7P 4B      TEXT('% System ASP used *bin(4)')
         A            TOTAUX         5P 0B      TEXT('Total Aux storage *bin(4)')
         A            CURUNP         5P 0B      TEXT('Cur unprotect used *bin(4)')
         A            MAXUNP         5P 0B      TEXT('Max unprotect used *bin(4)')
    Nothing fancy because I didn't want anything more. I just wanted a regular record of a few trends. Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    Wow -- major typo... Call the QWCRSSTS API, not QWCCVTDT. I copy/pasted from the wrong CALL command in my comment. Tom
    125,585 pointsBadges:
    report
  • ten2008
    Hi Tom, thanks for your effort and patience. I want only those three field values mentioned in my questiion which shall be moved to another file after retrieving. thanks
    1,150 pointsBadges:
    report
  • TomLiotta
    I want only those three field values mentioned in my questiion which shall be moved to another file after retrieving. Well, those three and more available as you should see. Just pick the three that you need and ignore the rest. You might notice the I used DCLF SYSYSSTSPF in the program even though the program does not include any I/O for that file. (The SQL INSERT is executed in a different program.) I did that in order to bring all of the DCLs for variables in. I didn't have to code those. You would only need three DCLs for your three variables from the API. Many of the other variables could be removed since you won't need them. You'll end up with a smaller set of instructions. If you want to try creating your version and you run into trouble, post it here. We can probably fix it. Tom
    125,585 pointsBadges:
    report

Forgot Password

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

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following