Find out what's taking a bite out of your disk
by Ernie Malaga
The AS/400 has gained the reputation of being a storage-hungry machine, and there is much truth in this assessment. Both auxiliary and main storage are prey to the system's insatiable appetite, and considering the cost of additional storage, you may have asked yourself if there is a way to determine what's eating up the disk.
Unfortunately, OS/400 is not much help. Even though commands like Work with System Status (WRKSYSSTS) will tell you how much of your disk is used, it will not tell you what's using it.
Consider our own case. At Midrange Computing we have a B10 which started giving warning signals about two months ago, in the form of messages to QSYSOPR stating that "a serious storage condition may exist -- press Help." The Help key was not very helpful (pardon the pun). When we executed WRKSYSSTS , we saw that our auxiliary storage was 93% used, but it gave us absolutely no idea what was using so much space.
"No problem," we thought. Just run the Display Library (DSPLIB) command. After all, DSPLIB LIB(QSYS) OUTPUT(*PRINT) prints a list of libraries with their sizes. As luck would have it, however, this is not quite true. The sizes we obtained from DSPLIB were the sizes of the library directories only - - not the sizes of all the objects contained in the libraries, which is what we were after.
What we needed, then, was another command we could run to print a list of libraries and their actual sizes (the directory plus the sum of all objects). Believe it or not, there is no OS/400 command that will provide this for you. I was resigned to creating my own command -- Print Library Sizes (PRTLIBSIZ) . PRTLIBSIZ will give you a list of libraries and their sizes sorted either alphabetically or in decreasing size sequence. 1 gives you an idea of what PRTLIBSIZ will do for you.
What we needed, then, was another command we could run to print a list of libraries and their actual sizes (the directory plus the sum of all objects). Believe it or not, there is no OS/400 command that will provide this for you. I was resigned to creating my own command -- Print Library Sizes (PRTLIBSIZ) . PRTLIBSIZ will give you a list of libraries and their sizes sorted either alphabetically or in decreasing size sequence. Figure 1 gives you an idea of what PRTLIBSIZ will do for you.
Needless to say, PRTLIBSIZ was of great help in determining which libraries were taking up the most space, and we found a couple of surprises which we quickly zapped into oblivion: two test libraries that had been sitting in there for the longest time, well after their usefulness had ended. After some additional trimming, WRKSYSSTS now shows a healthy 81% usage.
PRTLIBSIZ uses a CL program, three RPG (or PL/I) programs, and two externally- described files. Let's review them in turn.
The PRTLIBSIZ Command
The PRTLIBSIZ command is listed in 2. As you can see, there is only one parameter, SORT, which can have the values *NAME and *SIZE, the default being *NAME. If you use *NAME, the catalog will be printed alphabetically by library name; selecting *SIZE will sort the list in decreasing library size order. The command processing program (CPP) is called LIB002CL.
The PRTLIBSIZ command is listed in Figure 2. As you can see, there is only one parameter, SORT, which can have the values *NAME and *SIZE, the default being *NAME. If you use *NAME, the catalog will be printed alphabetically by library name; selecting *SIZE will sort the list in decreasing library size order. The command processing program (CPP) is called LIB002CL.
The LIB002CL Program
Program LIB002CL is listed in 3. It gets the job done as follows:
Program LIB002CL is listed in Figure 3. It gets the job done as follows:
1. The Display Object Description (DSPOBJD) command is executed in order to obtain a list of all libraries on disk. Notice that the output is sent to an outfile, which is later used by program LIB002RG to initialize one record per library in work file LIB002WF.
2. The loop that follows reads all records from LIB002WF. For each record (library) read, a DSPOBJD is executed to obtain information about the objects in the library. Program LIB002RGA uses this information to update the LIB002WF record.
3. Next, the program runs WRKSYSSTS and copies the spool file into a database file. The next program, LIB002RGB, uses this information to determine the size of your disk.
4. If the sort option you took was *SIZE, OPNQRYF sorts file LIB002WF by library size.
5. Finally, we run program LIB002RGB to print the report.
Files Used
PRTLIBSIZ uses two externally-described files: database file LIB002WF (4), which contains one record per library on disk, along with various types of statistical information, and printer file LIB002P1 (5).
PRTLIBSIZ uses two externally-described files: database file LIB002WF (Figure 4), which contains one record per library on disk, along with various types of statistical information, and printer file LIB002P1 (Figure 5).
The RPG Programs
Program LIB002RG, which is shown in 6, simply writes a record in LIB002WF after initializing all fields to blanks or zeros. If you are using Release 3.0, you may want to simply use CLEAR WFREC on your first C-spec, followed by the three C-specs that move actual data. Then you can remove all the other C-specs (Z-ADD *ZERO, MOVE *BLANK) found before the WRITE op-code.
Program LIB002RG, which is shown in Figure 6, simply writes a record in LIB002WF after initializing all fields to blanks or zeros. If you are using Release 3.0, you may want to simply use CLEAR WFREC on your first C-spec, followed by the three C-specs that move actual data. Then you can remove all the other C-specs (Z-ADD *ZERO, MOVE *BLANK) found before the WRITE op-code.
7 shows program LIB002RGA, which reads one record from LIB002WF, then reads all records in QADSPOBJ, adding totals and determining the name of the largest object in the library. When all records in QADSPOBJ have been processed, the LIB002WF record is updated with all the statistics.
Figure 7 shows program LIB002RGA, which reads one record from LIB002WF, then reads all records in QADSPOBJ, adding totals and determining the name of the largest object in the library. When all records in QADSPOBJ have been processed, the LIB002WF record is updated with all the statistics.
Program LIB002RGB (see 8) is a pretty straightforward report program. The only "trick" is that it reads the third record of SYSSTS in order to determine the size of your disk -- SYSSTS is where we have placed the output of WRKSYSSTS, and it so happens that the size of your disk is in the third record. This may change in a future release of OS/400. When the report is printed, the last line will tell you what percentage of auxiliary storage is used by libraries. This percentage does not agree with WRKSYSSTS because WRKSYSSTS brings other factors into play such as microcode, IPL areas A and B, and the like.
Program LIB002RGB (see Figure 8) is a pretty straightforward report program. The only "trick" is that it reads the third record of SYSSTS in order to determine the size of your disk -- SYSSTS is where we have placed the output of WRKSYSSTS, and it so happens that the size of your disk is in the third record. This may change in a future release of OS/400. When the report is printed, the last line will tell you what percentage of auxiliary storage is used by libraries. This percentage does not agree with WRKSYSSTS because WRKSYSSTS brings other factors into play such as microcode, IPL areas A and B, and the like.
PL/I versions of these programs can be downloaded from the Midrange Computing BBS. When you download the PL/I version from the BBS, program LIB002CL will automatically reference the PL/I programs instead of the RPG programs.
Running PRTLIBSIZ
PRTLIBSIZ takes a long time to run. On our maxed-out B10, run times of 90 minutes are not uncommon. Although larger models may process information more rapidly, they are also likely to have more and larger libraries than our system does. At any rate, you should consider running PRTLIBSIZ only in batch mode.
There is a tool called PRTLIBANL found in IBM's QUSRTOOL library that will also give you the library sizes we are after, and much more information. The problem with it is that it takes many hours to run and prints multiple reports per library. PRTLIBSIZ is considerably faster and provides a report which is much easier to read. There is also a catch with PRTLIBANL -- when we ran it, it aborted with an array index error after two and a half hours of processing.
Optimizing PRTLIBSIZ
Installations that are running under Release 3.0 can optimize PRTLIBSIZ by using APIs instead of the DSPOBJD command. Conceivably, you can do everything with only one HLL program, which calls APIs to create user spaces, get information, and then print the report. Perhaps this way you would only have to take a coffee break when you run it, instead of going out to lunch.
APIs will be covered in an upcoming issue of Midrange Computing.
Where Has All My DASD Gone? - Library List Utility
Figure 1 Library sizes report (unable to reproduce)
Where Has All My DASD Gone? - Library List Utility
Figure 10 PL/I program LIB002PLA
lib002pla: procedure(library_updated); declare qadspobj file input record env(described), lib002wf file update record direct env(indexed described); declare 1 qadspobj_rec, %include qadspobj (qlidobjd, record); declare 1 lib002wf_rec, %include lib002wf (wfrec, record); declare 1 lib002wf_key, %include lib002wf (wfrec, key); declare library_not_found bit(1) aligned, library_updated char(10), more_records bit(1) aligned; declare 1 work, 2 objects_total_size fixed dec(12,0), 2 number_of_objects fixed dec(9,0), 2 largest_object_name char(10), 2 largest_object_type char(10), 2 largest_object_attribute char(10), 2 largest_object_size fixed dec(10,0); %include qplisrc (@yesno); on key(lib002wf) library_not_found = yes; on endfile(qadspobj) more_records = no; /* program nucleus */ more_records = yes; lib002wf_key.library_name = library_updated; read file(lib002wf) into(lib002wf_rec) key(lib002wf_key); if ªlibrary_not_found then do; work = ''; read file(qadspobj) into(qadspobj_rec); do while(more_records); if qadspobj_rec.odobtp ª= '*LIB' then do; work.objects_total_size = work.objects_total_size + qadspobj_rec.odobsz; end; work.number_of_objects = work.number_of_objects + 1; if qadspobj_rec.odobsz > work.largest_object_size then do; work.largest_object_name = qadspobj_rec.odobnm; work.largest_object_type = qadspobj_rec.odobtp; work.largest_object_attribute = qadspobj_rec.odobat; work.largest_object_size = qadspobj_rec.odobsz; end; read file(qadspobj) into(qadspobj_rec); end; lib002wf_rec = work, by name; lib002wf_rec.total_size = lib002wf_rec.library_size + lib002wf_rec.objects_total_size; rewrite file(lib002wf) from(lib002wf_rec) key(lib002wf_key); end; end lib002pla;
Where Has All My DASD Gone? - Library List Utility
Figure 11 PL/I program LIB002PLB
lib002plb: procedure; declare lib002wf file input record env(indexed described), syssts file input record direct, lib002p1 file output record env(described); declare 1 lib002wf_rec, %include lib002wf (wfrec, record); declare 1 syssts_rec, 2 unused_1 char(95), 2 total_storage_MB pic 'ZZZZZZ9', 2 unused_2 char(30); declare 1 lib002p1_header, %include lib002p1 (header, output); declare 1 lib002p1_detail, %include lib002p1 (detail, output); declare 1 lib002p1_total, %include lib002p1 (total, output); declare more_records bit(1) aligned, oncode builtin; %include qplisrc (@yesno); on endfile(lib002wf) more_records = no; on transmit(lib002p1) begin; if oncode = 44 then write file(lib002p1) from(lib002p1_header) options(record('header')); end; /* program nucleus */ more_records = yes; lib002p1_total = ''; write file(lib002p1) from(lib002p1_header) options(record('header')); read file(lib002wf) into(lib002wf_rec); do while(more_records); lib002p1_detail = lib002wf_rec, by name; lib002p1_detail.library_text_40 = substr(lib002wf_rec.library_text,1,40); write file(lib002p1) from(lib002p1_detail) options(record('detail')); lib002p1_total.total_storage_used = lib002p1_total.total_storage_used + lib002p1_detail.total_size; read file(lib002wf) into(lib002wf_rec); end; read file(syssts) into(syssts_rec) key(3); lib002p1_total.total_auxiliary_storage = syssts_rec.total_storage_MB * 1000000; lib002p1_total.percent_used = lib002p1_total.total_storage_used * 100 / lib002p1_total.total_auxiliary_storage; write file(lib002p1) from(lib002p1_total) options(record('total')); end lib002plb;
Where Has All My DASD Gone? - Library List Utility
Figure 12 PL/I routine @YESNO (used with PL/I programs)
/*******************************************************************/ /* */ /* declare program constants 'yes' and 'no' */ /* */ /*******************************************************************/ declare no bit(1) aligned init('0'b) static, yes bit(1) aligned init('1'b) static;
Where Has All My DASD Gone? - Library List Utility
Figure 2 Command PRTLIBSIZ
PRTLIBSIZ: CMD PROMPT('Print Library Sizes') PARM KWD(SORT) TYPE(*CHAR) LEN(5) RSTD(*YES) + DFT(*NAME) VALUES(*NAME *SIZE) + PROMPT('Sort option') PARM KWD(VERSION) TYPE(*CHAR) LEN(4) RSTD(*YES) + DFT(*RPG) VALUES(*PLI *RPG) PROMPT('Version')
Where Has All My DASD Gone? - Library List Utility
Figure 3 CL program LIB002CL
LIB002CL: + PGM PARM(&SORT &VERSION) DCLF FILE(LIB002WF) DCL VAR(&SORT) TYPE(*CHAR) LEN(5) DCL VAR(&VERSION) TYPE(*CHAR) LEN(4) DCL VAR(&PGMNAM) TYPE(*CHAR) LEN(10) CLRPFM FILE(LIB002WF) /* Store the names of all libraries in indexed file */ DSPOBJD OBJ(QSYS/*ALL) OBJTYPE(*LIB) OUTPUT(*OUTFILE) + OUTFILE(QTEMP/QADSPOBJ) OUTMBR(*FIRST *REPLACE) OVRDBF FILE(QADSPOBJ) TOFILE(QTEMP/QADSPOBJ) IF COND(&VERSION *EQ '*PLI') THEN(CHGVAR VAR(&PGMNAM) + VALUE(LIB002PL)) ELSE CMD(CHGVAR VAR(&PGMNAM) VALUE(LIB002RG)) CALL PGM(&PGMNAM) DLTOVR FILE(QADSPOBJ) /* Process all libraries one at a time */ LOOP: + RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDLOOP)) DSPOBJD OBJ(&WFLIB/*ALL) OBJTYPE(*ALL) OUTPUT(*OUTFILE) + OUTFILE(QTEMP/QADSPOBJ) OUTMBR(*FIRST *REPLACE) MONMSG MSGID(CPF2123) EXEC(GOTO CMDLBL(LOOP)) OVRDBF FILE(QADSPOBJ) TOFILE(QTEMP/QADSPOBJ) IF COND(&VERSION *EQ '*PLI') THEN(CHGVAR VAR(&PGMNAM) + VALUE(LIB002PLA)) ELSE CMD(CHGVAR VAR(&PGMNAM) VALUE(LIB002RGA)) CALL PGM(&PGMNAM) PARM(&WFLIB) DLTOVR FILE(QADSPOBJ) GOTO CMDLBL(LOOP) /* Get total storage on the system */ ENDLOOP: + OVRPRTF FILE(QPDSPSTS) HOLD(*YES) WRKSYSSTS OUTPUT(*PRINT) CRTPF FILE(QTEMP/SYSSTS) RCDLEN(132) CPYSPLF FILE(QPDSPSTS) TOFILE(QTEMP/SYSSTS) DLTOVR FILE(QPDSPSTS) DLTSPLF FILE(QPDSPSTS) /* Print report */ IF COND(&SORT *EQ '*SIZE') THEN(DO) OVRDBF FILE(LIB002WF) SHARE(*YES) OPNQRYF FILE((LIB002WF)) QRYSLT(*ALL) KEYFLD((WFTSIZ + *DESCEND) (WFLIB *ASCEND)) ENDDO IF COND(&VERSION *EQ '*PLI') THEN(CHGVAR VAR(&PGMNAM) + VALUE(LIB002PLB)) ELSE CMD(CHGVAR VAR(&PGMNAM) VALUE(LIB002RGB)) CALL PGM(&PGMNAM) IF COND(&SORT *EQ '*SIZE') THEN(DO) CLOF OPNID(LIB002WF) DLTOVR FILE(LIB002WF) ENDDO DLTF FILE(QTEMP/QADSPOBJ) DLTF FILE(QTEMP/SYSSTS) CLRPFM FILE(LIB002WF) ENDPGM
Where Has All My DASD Gone? - Library List Utility
Figure 4 Physical file LIB002WF
A UNIQUE A R WFREC A WFLIB 10 ALIAS(LIBRARY_NAME) A WFTEXT 50 ALIAS(LIBRARY_TEXT) A WFLBSZ 10P 0 ALIAS(LIBRARY_SIZE) A EDTCDE(1) A WFOBSZ 12P 0 ALIAS(OBJECTS_TOTAL_SIZE) A EDTCDE(1) A WFTSIZ 12P 0 ALIAS(TOTAL_SIZE) A EDTCDE(1) A WFOBJS 9P 0 ALIAS(NUMBER_OF_OBJECTS) A EDTCDE(1) A WFLRGN 10 ALIAS(LARGEST_OBJECT_NAME) A WFLRGT 10 ALIAS(LARGEST_OBJECT_TYPE) A WFLRGA 10 ALIAS(LARGEST_OBJECT_ATTRIBUTE) A WFLRGS 10P 0 ALIAS(LARGEST_OBJECT_SIZE) A EDTCDE(1) A K WFLIB
Where Has All My DASD Gone? - Library List Utility
Figure 5 Printer file LIB002P1
A REF(LIB002WF) A R HEADER SKIPB(3) A 1DATE EDTCDE(Y) A 11TIME EDTWRD('0 : : ') A 57'PRINT LIBRARY SIZES' A 110'PRTLIBSIZ - Page:' A 128PAGNBR EDTCDE(3) A SPACEA(3) A 1'Library' A 13'Library Text /' A 54'Largest Object' A 72'Number Of' A 88'Directory' A 104'Total Size' A 123'Total Size' A SPACEA(1) A 3'Name' A 13'Largest Object Name/Type/Attrib' A 59'Size' A 73'Objects' A 91'Size' A 104'Of Objects' A 123'Of Library' A SPACEA(2) * A R DETAIL A WFLIB R 1 A TEXT40 40 13ALIAS(LIBRARY_TEXT_40) A WFLRGS R 54 A WFOBJS R 70 A WFLBSZ R 83 A WFOBSZ R 99 A WFTSIZ R 117SPACEA(1) A WFLRGN R 13 A WFLRGT R +2 A WFLRGA R +2SPACEA(2) * A R TOTAL A 41'Total Auxiliary Storage:' A AUXSTG 12 0 66EDTCDE(1) A ALIAS(TOTAL_AUXILIARY_STORAGE) A 90'Total Storage Used:' A STGUSE 12 0 117EDTCDE(1) A ALIAS(TOTAL_STORAGE_USED) A SPACEA(1) A PCTUSE 5 2 126ALIAS(PERCENT_USED) A EDTCDE(1) A 132'%'
Where Has All My DASD Gone? - Library List Utility
Figure 6 RPG program LIB002RG
FQADSPOBJIP E DISK FLIB002WFO E DISK A * C MOVE ODOBNM WFLIB C MOVE ODOBTX WFTEXT C Z-ADDODOBSZ WFLBSZ C Z-ADD*ZERO WFOBSZ C Z-ADD*ZERO WFTSIZ C Z-ADD*ZERO WFOBJS C MOVE *BLANK WFLRGN C MOVE *BLANK WFLRGT C MOVE *BLANK WFLRGA C Z-ADD*ZERO WFLRGS C WRITEWFREC
Where Has All My DASD Gone? - Library List Utility
Figure 7 RPG program LIB002RGA
FQADSPOBJIF E DISK FLIB002WFUF E K DISK * C *ENTRY PLIST C PARM UPDLIB 10 LIBRARY UPDATED * C UPDLIB CHAINLIB002WF 90 B001 C *IN90 IFEQ '0' C Z-ADD*ZERO @OTS 150 OBJ TOTAL SIZE C Z-ADD*ZERO @NOO 90 NBR OF OBJECTS C MOVE *BLANK @LON 10 LARGEST OBJ NAM C MOVE *BLANK @LOT 10 LARGEST OBJ TYP C MOVE *BLANK @LOA 10 LARGEST OBJ ATR C Z-ADD*ZERO @LOS 100 LARGEST OBJ SIZ C READ QADSPOBJ 91 B002 C *IN91 DOWEQ'0' C MOVELODOBTP X8 8 B003 C X8 IFNE '*LIB ' C ADD ODOBSZ @OTS E003 C END C ADD 1 @NOO B003 C ODOBSZ IFGT @LOS C MOVE ODOBNM @LON C MOVE ODOBTP @LOT C MOVE ODOBAT @LOA C Z-ADDODOBSZ @LOS E003 C END C READ QADSPOBJ 91 E002 C END C Z-ADD@OTS WFOBSZ C WFLBSZ ADD WFOBSZ WFTSIZ C Z-ADD@NOO WFOBJS C MOVE @LON WFLRGN C MOVE @LOT WFLRGT C MOVE @LOA WFLRGA C Z-ADD@LOS WFLRGS C UPDATWFREC E001 C END * C MOVE '1' *INLR
Where Has All My DASD Gone? - Library List Utility
Figure 8 RPG program LIB002RGB
FLIB002WFIF E K DISK FSYSSTS IF F 132 DISK FLIB002P1O E 99 PRINTER * ISYSSTS NS I 96 1020STGMB * C Z-ADD*ZERO AUXSTG C Z-ADD*ZERO STGUSE C Z-ADD*ZERO PCTUSE C WRITEHEADER * C READ LIB002WF 90 B001 C *IN90 DOWEQ'0' C MOVELWFTEXT TEXT40 B002 C *IN99 IFEQ '1' C WRITEHEADER C MOVE '0' *IN99 E002 C END C WRITEDETAIL C ADD WFTSIZ STGUSE C READ LIB002WF 90 E001 C END * C 3 CHAINSYSSTS 90 C STGMB MULT 1000000 AUXSTG C STGUSE MULT 100 TEMP 150 C TEMP DIV AUXSTG PCTUSE C WRITETOTAL * C MOVE '1' *INLR
Where Has All My DASD Gone? - Library List Utility
Figure 9 PL/I program LIB002PL
lib002pl: procedure; declare qadspobj file input record env(described), lib002wf file output record env(described); declare 1 qadspobj_rec, %include qadspobj (qlidobjd, record); declare 1 lib002wf_rec, %include lib002wf (wfrec, record); declare more_records bit(1) aligned; %include qplisrc (@yesno); on endfile(qadspobj) more_records = no; /* program nucleus */ more_records = yes; read file(qadspobj) into(qadspobj_rec); do while(more_records); lib002wf_rec = ''; lib002wf_rec.library_name = qadspobj_rec.odobnm; lib002wf_rec.library_text = qadspobj_rec.odobtx; lib002wf_rec.library_size = qadspobj_rec.odobsz; write file(lib002wf) from(lib002wf_rec); read file(qadspobj) into(qadspobj_rec); end; end lib002pl;
LATEST COMMENTS
MC Press Online