Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
Retrieving Disk Percentage Used?
has no ratings.
Published: 03 Jan 2012
Revised: 21 Jul 2015 - 3173 days ago
Last viewed on: 28 Mar 2024 (14221 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Retrieving Disk Percentage Used? Published by: Bob Cozzi on 03 Jan 2012 view comments(13)

I would like to start logging the current percentage of disk use. I looked at the QYASRDI API but it doesn't seem to return the Percentage Used figure. Does anyone know of another API that would return the DISK USAGE percentage or at least the disk capacity and amount used so I could do the calculation myself?

I'm doing this because we have a lot of systems and would like to monitor which ones reach a threshold that is set by management but is NOT related to critical disk utilization. That is, if we are running at 70% but then after a month-end run jump up to 85% usage, we want to know that so we can look at the systems that may have contributed to this jump in utilization.

We're planning on replacing the systems over the next two years and lets just say there are several legacy S/36-style application designs in place which do things like CPYF, FMTDATA and other goofy techniques that could easily have been done with LOGICAL views or better yet, SQL.

We will prioritize the app changes based on those that consume the most DASD, hence the need to know if there is an API that can retrieve that piece of information.

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: captndjc
Premium member *
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 25 days 18 hours 50 minutes ago

Bob, We use Robot. It has a PRTDSKSPC command that does this for you if you have Robot.

The other thought is to use the RTVDSKINF command but you will have to write something to build your history from this command.

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 25 days 18 hours 37 minutes ago

See Retrieve System Status (QWCRSSTS) API. Unfortunately I didn't grab it when I left my last assignment, or I could give you sample code. I believe you want SSTS0200, fields for System ASP and % system ASP used.

Don't see an easy way if you have more than system ASP. Haven't used it, but maybe Open List of ASPs (QYASPOL) API.

Posted by: JOHND1
Premium member *
Milford, Ma
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 25 days 18 hours 36 minutes ago

If you use rtvdskinf to gather in infor you can use prtdskinf to print it, both opjects are created by *IBM.  RTVDSKINF will build a fle and PRTDSPINF allows you to print it. we run this on the weekend and review it on Monday morning

 

                       Print Disk Information (PRTDSKINF)                     
                                                                             
Type choices, press Enter.                                                   
                                                                             
Type of report . . . . . . . . . > *OBJ          *LIB, *FLR, *OWN, *OBJ, *SYS
ASP device . . . . . . . . . . .   *SYSBAS       Name, *SYSBAS               
Objects  . . . . . . . . . . . .   *NONE         Name, generic*, *ALL, *NONE 
Object types . . . . . . . . . .   *ALL          *ALL, *ALRTBL, *AUTL...     
               + for more values                                             
Smallest size  . . . . . . . . .   0             Size in 1000 bytes          
Sort by  . . . . . . . . . . . .   *SIZE         *SIZE, *OWNER, *LSTCHG...   
                                                                             
                                                                             
                                                                             
                                                                             

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 25 days 18 hours 2 minutes ago

RTVDSKINF needs system more or less quiesced. It collects attributes of all objects, which takes awhile, and you don't want a lot of things changing while it's running. PRTDSKINF is predefined reports over the file that it creates. The file is visible, so you could write your own queries.

The QWCRSSTS API is what you get from DSPSYSSTS or WRKSYSSTS. Pretty much instantaneous. If all you need to know is what % of disk is used, this is probably easier and definitely faster.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 25 days 15 hours 48 minutes ago

Thanks Dale, QWCRSSTS is what I was looking for.

I like the RTVDSKINF/PRTDSKINF commands and have used them to do clean up. But what I was looking for is a way to notify a centralized location of the disk utilization and provide  trending information. QWCRSSTS should do that for me with some help from database.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 24 days 20 hours 37 minutes ago

The QWCRSSTS API is okay, but only provides the total disk usage percentage, not detail info on a disk unit basis. What I really need is a WRKDSKSTS API not the WRKSYSSTS. Is there one?

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 24 days 18 hours 47 minutes ago

I don't think there is one. Saw one article, I think it was on systeminetwork, that mentioned that WRKDSKSTS uses MATRMD MI instruction (good luck with that). Hate to suggest this, but best option might be to WRKDSKSTS OUTPUT(*PRINT) and read the spooled file.

Posted by: bdietz400
Premium member *
columbus, oh
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 9 days 16 hours 19 minutes ago

On a V7.1 system I have a file QSYS2/sysdisks  that contains the data you are looking for.
I cannot seem to find(quickly) when it was added to the OS.

Bryan

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 9 days 12 hours 15 minutes ago

I don't see it on v5r2 or v5r4. I don't have a v6r1 machine.

Posted by: bdietz400
Premium member *
columbus, oh
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 8 days 19 hours 56 minutes ago

As mentioned before this API will list the disk units:
Open List of ASPs (QYASPOL) API   format YASP0300

http://as400bks.rochester.ibm.com/iseries/v5r2/ic2924/index.htm?info/apis/qyaspol.htm#HDRYASPL5

 

32     20     BINARY(4)     Disk unit number
36     24     BINARY(4)     Disk capacity
40     28     BINARY(4)     Disk storage available

Posted by: Viking
Premium member *
CA
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 8 days 15 hours 15 minutes ago

QSYS2/sysdisks

I'm on 6.1 and I don't have this object.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 5 days 20 hours 28 minutes ago

bryan, I'm looking into the API method QYASPOL. I've got it running, but not working. :)

Meaning it runs fine, but I can figure out the QGY list stuff. Very odd design if you ask me.But I'll get it working and post it when I have time. Thanks for the suggestion.

FYI: What I'm doing is managing 10 systems on different islands. Each morning at 6:00 AM I have a job scheduled to run that currently produces a DSPDSKSTS OUTPUT(*PRINT) report and I send that to a remote outq on my system. So I end up with 10 spool file entries and look through each of them.

A few weeks ago, I used on of the APIs and got the System Status disk percentage used returned and I write that out to a log file, which is a DDM file. That too runs in that morning job.

So I get the overall disk percentage, but I need to know that figure for each disk drive. WHy? Because they have 4, 6 or 8 drives in each system and in ZERO instances are those drives the same capacity. So 10% on one drive might be 400MB while another drive it could be 3.5GB.

The good news is i ran the STRASPBAL command and sort of evened out the usage on the drives, and that's helped.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Retrieving Disk Percentage Used?
Posted: 12 years 2 months 5 days 13 hours 32 minutes ago
Edited: Mon, 23 Jan, 2012 at 16:55:34 (4448 days ago)

Well, I've got it working.

I stubbed out the essential code so I could show it here.

 

.....H BNDDIR('QC2LE') OPTION(*NODEBUGIO:*SRCSTMT)
     H DFTACTGRP(*NO) ACTGRP(*NEW) EXTBININT(*YES)
     H Copyright('(c) 2012 by Robert Cozzi, Jr.')

      *** Delete next 2 lines if you don't want to write to the joblog
     H BNDDIR('RPGOPEN/RPGOPEN')
      /copy rpgopen/qcpysrc,joblog

      /copy qsysinc/qrpglesrc,qusec
      /copy qsysinc/qrpglesrc,qgy
      /copy qsysinc/qrpglesrc,qyaspol
      /copy qsysinc/qrpglesrc,qusgen

     D listSpace       S          65535A
     D QYASP0300_T     DS                  LikeDS(QYAP0300) Inz
     D diskUnit        DS                  LikeDS(QYASP0300_T) Inz
     D DU              DS                  LikeDS(QYASP0300_T) Based(pDiskUnit)
     D pDiskUnit       S               *   InZ(%addr(diskUnit))

     D closeOpenList   PR                  extPgm('QGY/QGYCLST')
     D  handle                        4A   OPTIONS(*VARSIZE)
     D  apiErrorDS                         LikeDS(QUSEC) OPTIONS(*VARSIZE)

     D getOpenListE    PR                  extPgm('QGY/QGYGTLE')
     D  rtnValue                  65535A   OPTIONS(*VARSIZE)
     D  rtnValueLen                  10I 0 Const
     D  handle                        4A   Const
     D  listInfo                     80A   OPTIONS(*VARSIZE)
     D  reqRtnCount                  10I 0 Const
     D  strRcd                       10I 0 Const
     D  apiErrorDS                         LikeDS(QUSEC) OPTIONS(*VARSIZE)

     D openASPList     PR                  extPgm('QGY/QYASPOL')
     D  rtnValue                  65535A   OPTIONS(*VARSIZE)
     D  rtnValueLen                  10I 0 Const
     D  listInfo                     80A   OPTIONS(*VARSIZE)
     D  reqRtnCount                  10I 0 Const
     D  filterCount                  10I 0 Const
     D  filterInfo                   80A   OPTIONS(*VARSIZE)
     D  apiFormat                     8A   Const
     D  apiErrorDS                         LikeDS(QUSEC) OPTIONS(*VARSIZE)

     D openFilter      DS                  Qualified Inz
     D  entrySize                    10I 0 Inz(%size(openFilter))
     D  Key                          10I 0 Inz(1)
     D  dataSize                     10I 0 Inz(4)
     D  data                         10I 0 Inz(-1)

     D openListInfo    DS                  Qualified
     D  rcdAvail                     10I 0
     D  rtnRcdCount                  10I 0
     D  Handle                        4A
     D  rcdLen                       10I 0
     D  complete                      1A
     D  crtDTS                       13A
     D  status                        1A
     D  reserved                      1A
     D  rtnLen                       10I 0
     D  rcdOffset                    10I 0
     D  reserved2                    40A

     D  apiError       DS                  LikeDS(QUSEC) Inz
     D  rcdCount       S             10I 0

     D i               S             10I 0
     D perUsed         S              7P 2
     D perFree         S              7P 2
     C                   MOVE      *ON           *INLR
      /free
          openASPList( listSpace : %size(listSpace) : openListInfo :
                       -1 : 1 : openFilter : 'YASP0300' : apiError );
          rcdCount = openListInfo.rtnRcdCount;
          for i = 1 to rcdCount;
          getOpenListE(diskUnit : %size(diskUnit) : openListInfo.Handle :
                          openListInfo : 1 : i : apiError );
           // At this point, the DiskUnit struct has the returned Disk info.
             // Calc the percentage used and free for each disk unit
           perFree = %DEC((du.qyaiable / du.qyatotal00) * 100 : 7: 2);
           perUsed = 100 - perFree;

          // START -- Delete if you don't want to write to the joblog
             // Use RPGOPEN.com's joblog() API to record to joblog
           Joblog('Disk(%s) Type(%s/%s) Serial(%s) Res(%s) +
                   ASP(%s) %s':
                     %Char(du.qyaunbr)    : // Unit Number
                     %TrimR(du.qyatype00) : // Disk type
                     %TrimR(du.qyamodel)  : // Model
                     %TrimR(du.qyasnbr)   : // Serial Number
                     %TrimR(du.qyaource)  : // Resource ID
                     %Char(du.qyaumber01) : // ASP Number
                     %TrimR(du.QYACS));     // Disk Status
           Joblog(' + Capacity: %s Free %s Percentage Used(%s)' :
                     %char(du.qyatotal00) : // Size
                     %char(du.qyaiable)   : // Available
                     %char(perUsed) );      // % Used
          // END -- Delete if you don't want to write to the joblog

          endfor;
          closeOpenList( openListInfo.Handle : apiError);
          return;

      /end-free