[Access to Wang masthead]

The FILEDATA Procedure

Gathering file usage data

From "VS Procedure",  Access 87, July 1987
  [ Prior Article ]     [ Return to the Catalog of articles ]     [ Next Article ]  

Proper management of disk space on VS systems requires that the administrator review the system's disk space usage from a grand perspective. With a potential for thousands of files, file usage information must be summarized and selected by overall priority to be useful. The unique nature of each shop's disk usage ensures that the file usage data needed to manage that system will also be unique. Unfortunately, there are few disk usage tools available that allow ad hoc reporting to meet these individual needs.

This month's procedure attempts to do just that. By gathering data on file usage in libraries meeting specified naming conventions, FILEDATA allows analysis of disk usage that can be specifically tailored to user needs.

The FILEINFO Utility

The heart of FILEDATA lies in its use of the FILEINFO Useraid. FILEINFO reads the Volume Table of Contents (VTOC) for entries on the files in a library, then builds a work file containing the data. Since this file is easily summarized with the REPORT utility, it is possible to create custom reports of specific file attributes. For example, I have made daily use of a report that computes the ratio of blocks used in a file versus those allocated, reporting on those files with a usage factor of less than 85%.

FILEINFO collects the following data on all files in a given library:

When run, FILEINFO prompts the user for the library and volume to be scanned. Pressing PF 14 at this point describes the data that will be amassed on the files in the library. After keying in valid library and volume names, the utility prompts for the location of the output file to be created. When the run is complete, the program ends.

Like other Useraids, FILEINFO is distributed by the International Society of Wang Users (ISWU), a Wang-supported national organization of Wang users. As usual, there is little information available as to its origin or use - though internal program documentation meets most of these needs.

Since the usual method of using the data compiled by FILEINFO is with the Wang REPORT utility, you must create a control file and REPORT file using FILEDATA. The FILEDATA procedure allows you to run any such REPORT of your choosing.

A new front-end

As useful as the FILEINFO utility is, it only provides information on one library's files. What if you wanted to know the total block allocations for all DSB libraries beginning with DSB? How about the all files in production libraries that are currently in more than one extent? These and other questions are easily resolved with the front-end provided by the FILEDATA procedure.

FILEDATA uses the FIND subroutine to extract all libraries on the system that meet the entered qualifications. Much of the code for this was borrowed from the WORKBNCH procedure featured in the December column, so I won't go into detail on how this is used. Suffice to say that FIND accepts partial file, library, and volume names - including the "wild card" characters '?' and '*' - and returns valid file, library, and volume names from the system. Entries that contain these wild card elements are often referred to as masked.

In addition to the library name, the user is also prompted for the location of the REPORT file to be run against the collected file information. Note that the procedure initially assumes that the REPORT definition lies in the current user's RPT library. As each library is identified, its name is passed to FILEINFO, which creates a work file of the data corresponding to that library. Each of these work files is then summarized via the user's REPORT definition. Finally, the work file is scratched and the next library name if processed. For the convenience of the user, I have included a call to the DISPRINT utility so the completed reports can be examined easily.

The REPORTIT subsection contains a few items of note to serious Procedure users. First is the use of ambiguous file names for the work file. Note the 'O1:' label and work file name of '##WORK': these tell the Procedure Interpreter to assign a unique file name to the output file that begins with 'WORK' and to store that name in a label reference call 'O1'. In the next step, the REPORT utility refers to this work file (the INPUT1 GETPARM) by simply referencing the label; the related file, library, and volume information is entered automatically. Upon conclusion of the report, the SCRATCH command also refers to this file through the label 'O1'. The advantages to this method of file naming are that file names will always be unique and that the file will be located in the user's work library and volume and thus be scratched automatically upon logoff. (As a general rule, I don't wait that long; I prefer to scratch work files when they are no longer needed by the process that created them.)

The other item of note is the GETPARM screen within REPORT marked ERROR2. This screen appears whenever the data does not match the selection criteria for the report, and thus no report will be produced. Since it is quite likely that no files will meet the selection criteria I impose in the REPORT definition, I have chosen to suppress this screen with an ENTER statement.

Some applications

Some of the applications I have put this procedure to include:

1. An exception report listing all data files with greater than one extent allocated.

2. A summary report of block usage versus allocation by library.

3. A report of all files on the system belonging to one user, sorted in descending order by blocks allocated.

I'm sure other reports will come to mind for your application. Bear in mind, however, that the FILEINFO utility creates a separate file for each library, and that comparisons across library lines will require merging these discrete work files into one. The FILEINFO utility also allows only file digits for block usage and only six for record count; in cases where the file is larger, FILEINFO will substitute zero for any of these values.

Next month we'll discuss the application of other common utilities for system management. In the meanwhile, I hope you find use for FILEINFO and the FILEDATA procedure. I look forward to your comments and suggestions.


Figure 1: The FILEDATA Procedure


     PROCEDURE FILEDATA - gathers data on files in a library

* Variables used by FIND

     DECLARE &FFIL       STRING (08)
     DECLARE &FLIB       STRING (08)
     DECLARE &FVOL       STRING (06)
     DECLARE &FSTART     INTEGER
     DECLARE &FCOUNT     INTEGER
     DECLARE &FRCVR      STRING (440)
     DECLARE &FFILES     INTEGER

* Variables used by FILEINFO

     DECLARE &ILIB       STRING (08)
     DECLARE &IVOL       STRING (06)

* Variables used by REPORT

     DECLARE &RFIL       STRING (08)
     DECLARE &RLIB       STRING (08)
     DECLARE &RVOL       STRING (06)
     DECLARE &ID         STRING (03)

* Screen control variables

     DECLARE &KEY        INTEGER
     DECLARE &MESSAGE    STRING (78)

* Program control variables

     DECLARE &LOOP       INTEGER

* Extract initial LIBRARY and VOLUME for report

     EXTRACT             &RVOL     = INVOL,
                         &ID       = USERID

     ASSIGN &RLIB        = &ID(1,*) !! "RPT"

* --- * MAIN LOGIC BEGINS:

S00: ASSIGN &FLIB        = " "
     ASSIGN &FVOL        = " "
     ASSIGN &FRCVR       = " "
     ASSIGN &FSTART      = -19
     ASSIGN &FCOUNT      = 20

S01: PROMPT              PFKEY     = &KEY
     CENTER BRIGHT LINE "FILEDATA - Finds data on files";;
     CENTER "This procedure creates a work file of data regarding ",
            "the specified";
     CENTER "libraries, then selectively reports on that data.  ",
            "You may use";
     CENTER "either discrete or ABBIGUOUS library names (e.g. ",
            "'*' replaces one";
     CENTER "character; '?' replaces any combination of ",
            "characters).";;
     CENTER "Enter the libraries and volumes to be searched:";;
     CENTER "  DATA LIBRARY =", UPPER &FLIB;
     CENTER "  DATA VOLUME  =", UPPER &FVOL, " ";;
     CENTER "Enter the REPORT to be used:";;
     CENTER "REPORT FILE    =", UPPER &RFIL;
     CENTER "REPORT LIBRARY =", UPPER &RLIB;
     CENTER "REPORT VOLUME  =", UPPER &RVOL, " ";;
     CENTER "Press PF14 to display print files";
     CENTER "Press PF16 to exit               ";;

     IF &KEY = 14        GOTO DISPRT
     IF &KEY = 16        GOTO S99
     IF &KEY <> 0        GOTO S01

     IF &FLIB = " "      GOTO S01
     IF &FVOL = " "      GOTO S01

     IF &RFIL = " "      GOTO S01
     IF &RLIB = " "      GOTO S01
     IF &RVOL = " "      GOTO S01

     IF NOT EXISTS FILE &RFIL IN &RLIB ON &RVOL        GOTO S01

S02: ASSIGN &FSTART      = &FSTART + &FCOUNT
     ASSIGN &FRCVR       = " "

     RUN FIND IN VSSUBS            USING &FFIL,    &FLIB,
                                         &FVOL,    &FSTART,
                                         &FCOUNT,  &FRCVR,
                                         &FFILES,  "A"

     ASSIGN &LOOP        = 0

S03: ASSIGN &LOOP        = &LOOP + 1
     IF &LOOP > 20       GOTO S02
     IF &FRCVR ((&LOOP * 22)-21,22) = " "    GOTO S04

     ASSIGN &IVOL        = &FRCVR ((&LOOP * 22)-21,6)
     ASSIGN &ILIB        = &FRCVR ((&LOOP * 22)-21,8)
     CALL REPORTIT
     GOTO S03

S04: GOTO S00

S99: RETURN

*********************************************************************
*                     SUBROUTINES FOLLOW                            *
*********************************************************************
DISPRT:

     RUN DISPRINT IN VSSUBS

     GOTO S01

REPORTIT:

     RUN FILEINFO IN VSAIDS
     CANCEL EXIT IS S99
     ENTER VOLUME        LIBRARY   = &ILIB,
                         VOLUME    = &IVOL
O1:  ENTER FILEINFO      FILE      = ##WORK,
                         RECORDS   = 1500

     RUN REPORT
     ENTER FUNCTION      04
     ENTER OPTIONS       ID        = &RFIL,
                         FILES     = YES,
                         OPTION    = YES,
                         SPACING   = 100
     ENTER RPTDEF        FILE      = &RFIL,
                         LIBRARY   = &RLIB,
                         VOLUME    = &RVOL
     ENTER OUTPUT        (O1)
     ENTER ERROR2
     ENTER FUNCTION      16

     SCRATCH (O1)
     END

  [ Prior Article ]     [ Return to the Catalog of articles ]     [ Next Article ]  


Copyright © 1987 Dennis S. Barnes
Reprints of this article are permitted without notification if the source of the information is clearly identified