DASDSCAN - search for possible space problems

This program is for a mvs3.8j system. It's purpose is to check space usage on the dasd volumes.
Mainly because I was hard coding volsers in my JCL and I ran out of space on a volume... and rather than do the sensible thing of just checking space before I run a job I thought I would produce a report I will never read instead :-).
and it was an excuse to poke around in control blocks again.

Origionally I just wanted something to scan all online dasd, until I found the IBM manual that said that was not possible for all disks as noted below.
Anyway, this is what we have

Method 1: Check all online disks

Check all online disks to ensure there is enough free space remaining on each disk; free cylinders and dscbs.
Where possible also check all disk files on that disk to make sure they are not running out of space.

The where possible issue is as documented in the IBM Manual GCC28-0627-2 OS/VS2 MVS System Programming Library: Job Management it is not possible to use dynamic allocation on volumes mounted 'privat' so while dasd space usage can be checked for those; using the dynamic allocation method cannot check the files on the disk in those cases.

The JCL below will check all online dasd. It will do dasd space checks and both WTO and report to the rpterror file the volumes it was not able to dynalloc for filespace checks.

//TESTIT1  EXEC PGM=DASDSCAN,DYNAMNBR=3
//RPTVOLS  DD   SYSOUT=*         FOR VOLUME SPACE LISTINGS
//RPTERROR DD   SYSOUT=*         FOR ERROR/EXCEPTION REPORTING

Method 2:Using JCL to allocate/check volumes mounted 'privat'

Volumes mounted 'privat' can still be used using JCL to allocate them so the program allows you to chose volumes to be checked using JCL DD cards also.
Using JCL DD cards will only check the volumes you specify rather that all online volumes. But at least you can still check the volumes that cannot be used for dynamic allocation easily by using the JCL DD cards.

//TESTIT2  EXEC PGM=DASDSCAN
//RPTVOLS  DD   SYSOUT=*         FOR VOLUME SPACE LISTINGS
//RPTERROR DD   SYSOUT=*         FOR ERROR/EXCEPTION REPORTING
//* Using DDnnnn cards overides the scanning for all online
//* dasd devices and only uses the volsers provided.
//* Using JCL allows access to volsers that cannot be accessed
//* using dynamic allocation.
//DD1      DD   DISP=SHR,UNIT=3350,VOL=SER=MVSRES     CHECK MVSRES
//DD2      DD   DISP=SHR,UNIT=3350,VOL=SER=SRCMD1     CHECK SRCMD1

Program Source

If you think this may be useful to you this is the latest unstable source code. The latest stable version is in my github repository.

I will be adding enhancements to this as mentioned in the comments in the code, so check back occasionally. You may also be interested in my MDFILCHK program which checks individual dataset space usage and kicks off a maintenance job if the dataset threshold is exceeded.

Example Output

This is an example of running the job to check all online dasd, the joblog and the two report files produced. I should probably change the WTO to say dataset checks skipped rather than implying the disk is skipped as it still checks the disk for free space, just doesn't do any dataset extent allocation checks.

18.21.18 JOB   18  $HASP373 MARKDSCN STARTED - INIT  1 - CLASS A - SYS MID1
18.21.18 JOB   18  IEF403I MARKDSCN - STARTED - TIME=18.21.18
18.21.19 JOB   18  +MVSRES MOUNTED PRIVATE/RESERVED, NO DYNALLOC, SKIPPED
18.21.20 JOB   18  +PAGE00 MOUNTED PRIVATE/RESERVED, NO DYNALLOC, SKIPPED
18.21.20 JOB   18  +PAGE01 MOUNTED PRIVATE/RESERVED, NO DYNALLOC, SKIPPED
18.21.20 JOB   18  +PAGE02 MOUNTED PRIVATE/RESERVED, NO DYNALLOC, SKIPPED
18.21.21 JOB   18  +MVSDLB MOUNTED PRIVATE/RESERVED, NO DYNALLOC, SKIPPED
18.21.22 JOB   18  +CBT001 MOUNTED PRIVATE/RESERVED, NO DYNALLOC, SKIPPED
18.21.22 JOB   18  +CBT002 MOUNTED PRIVATE/RESERVED, NO DYNALLOC, SKIPPED
18.21.22 JOB   18  +CBTCAT MOUNTED PRIVATE/RESERVED, NO DYNALLOC, SKIPPED
18.21.22 JOB   18  +SRC000 MOUNTED PRIVATE/RESERVED, NO DYNALLOC, SKIPPED
18.21.22 JOB   18  +SRC001 MOUNTED PRIVATE/RESERVED, NO DYNALLOC, SKIPPED
18.21.22 JOB   18  +SRC002 MOUNTED PRIVATE/RESERVED, NO DYNALLOC, SKIPPED
18.21.22 JOB   18  +SRCCAT MOUNTED PRIVATE/RESERVED, NO DYNALLOC, SKIPPED
18.21.22 JOB   18  IEFACTRT - Stepname  Procstep  Program   Retcode
18.21.22 JOB   18  MARKDSCN   DASDSCAN            DASDSCAN  RC= 0000
18.21.22 JOB   18  IEF404I MARKDSCN - ENDED - TIME=18.21.22
18.21.22 JOB   18  $HASP395 MARKDSCN ENDED

            ---ATTRIBUTES----      AVAIL -----TOTALS---- LARGEST-EXTENT 5 EXTS
SERIAL UNIT   MOUNT      USE  VSAM DSCBS TRACKS  EXT CYL CYL+TR  TRACKS TRACKS
SORT01  131 RESIDENT  PUBLIC   OFF   473   3980    1 199 199+ 0    3980   3980
SORT02  132 RESIDENT  PUBLIC   OFF   473   3980    1 199 199+ 0    3980   3980
SORT03  133 RESIDENT  PUBLIC   OFF   473   3980    1 199 199+ 0    3980   3980
SORT04  134 RESIDENT  PUBLIC   OFF   473   3980    1 199 199+ 0    3980   3980
SORT05  135 RESIDENT  PUBLIC   OFF   473   3980    1 199 199+ 0    3980   3980
SORT06  136 RESIDENT  PUBLIC   OFF   473   3980    1 199 199+ 0    3980   3980
WORK00  140 RESIDENT  PUBLIC   OFF  1360  16500    1 550 550+ 0   16500  16500
SYS001  141 RESIDENT  PUBLIC    ON   861  15296    3 509 505+20   15170  15296
SRCMD1  146 RESIDENT  PUBLIC    ON   843  14184    6 469 465+15   13965  14182
MVSRES  148 RESIDENT  PRIVATE   ON  1279   4309    4 142 142+ 0    4260   4309
SMP001  149 RESIDENT  PUBLIC   OFF  1360   1620    1  54  54+ 0    1620   1620
SMP002  14A RESIDENT  PUBLIC   OFF  1359   1500    1  50  50+ 0    1500   1500
SMP003  14B RESIDENT  PUBLIC   OFF  1359   1500    1  50  50+ 0    1500   1500
SMP004  14C RESIDENT  PUBLIC   OFF  1334  14607    7 484 322+20    9680  14596
VSAM01  151 RESIDENT  PUBLIC    ON   582  14607    7 484 322+20    9680  14596  ALERTS REPORTED FOR THIS DISK
HASP00  152 RESERVED  PUBLIC   OFF   698   1748    1  92  92+ 0    1748   1748
MDSMP1  153 RESIDENT  PUBLIC   OFF   582   7584    2 399 399+ 0    7581   7584
PAGE00  160 RESIDENT  PRIVATE  OFF   237    372    1  31  31+ 0     372    372  ALERTS REPORTED FOR THIS DISK
PAGE01  161 RESIDENT  PRIVATE  OFF   238    396    1  33  33+ 0     396    396  ALERTS REPORTED FOR THIS DISK
PAGE02  162 RESERVED  PRIVATE  OFF   239   3528    1 294 294+ 0    3528   3528
WORK01  170 RESERVED  PUBLIC   OFF  2956  11478    1 956 956+ 6   11478  11478
WORK02  180 RESERVED  PUBLIC   OFF  3332  13185    1 879 879+ 0   13185  13185
PUB001  181 RESERVED  STORAGE  OFF  1003  12825    1 855 855+ 0   12825  12825
WORK03  190 RESERVED  PUBLIC   OFF  1419  16650    1 110 110+ 0   16650  16650
MVSCAT  191 RESERVED  STORAGE   ON  1292  13605   19 897 883+13   13258  13456
PUB000  240 RESIDENT  STORAGE   ON  1325  13600    4 453 422+ 0   12660  13600
MVSDLB  248 RESIDENT  PRIVATE   ON  1282   5982    8 199 175+ 0    5250   5977
PUB002  280 RESERVED  STORAGE  OFF  3278  21899    9 458 429+ 0   21435  21869
CBT000  340 RESIDENT  PUBLIC   OFF  1214    143    3   3   3+20     110    143  ALERTS REPORTED FOR THIS DISK
CBT001  341 RESIDENT  PRIVATE  OFF  1009    392    2  13  13+ 0     390    392  ALERTS REPORTED FOR THIS DISK
CBT002  342 RESIDENT  PRIVATE  OFF  1041   1091    1  36  36+11    1091   1091  ALERTS REPORTED FOR THIS DISK
CBTCAT  343 RESIDENT  PRIVATE   ON  1223   5795    2 193 193+ 0    5790   5795
SRC000  348 RESIDENT  PRIVATE  OFF  1284    291    2   8   6+13     193    291  ALERTS REPORTED FOR THIS DISK
SRC001  349 RESIDENT  PRIVATE  OFF  1253    280    1   9   9+10     280    280  ALERTS REPORTED FOR THIS DISK
SRC002  34A RESIDENT  PRIVATE  OFF  1300    430    1  14  14+10     430    430  ALERTS REPORTED FOR THIS DISK
SRCCAT  34B RESIDENT  PRIVATE   ON  1351  14112    2 470 470+ 0   14100  14112

SRCMD1  FILE > 10 EXTENTS: GAMES.DUCHESS.SOURCE
SRCMD1  FILE > 10 EXTENTS: INSTALL.UTILS.BKBYVTOC
SMP004  FILE > 10 EXTENTS: SYS1.SMPSTS
SMP004  FILE > 10 EXTENTS: RAKF.V102.PTFDATA.RRKF004E
SMP004  FILE > 10 EXTENTS: RAKF.V102.PTFDATA.RRKF006E
VSAM01  *** VOLUME CONTAINS NO FREE SPACE ***
PAGE00  HAS LESS THAN 050 CYLS IN LARGEST EXTENT
PAGE01  HAS LESS THAN 050 CYLS IN LARGEST EXTENT
PUB000  FILE > 10 EXTENTS: MARK.LIB.LOAD
PUB000  FILE > 10 EXTENTS: MARK.SMP.LIB.JCL
CBT000  HAS LESS THAN 050 CYLS IN LARGEST EXTENT
CBT001  HAS LESS THAN 050 CYLS IN LARGEST EXTENT
CBT002  HAS LESS THAN 050 CYLS IN LARGEST EXTENT
SRC000  HAS LESS THAN 050 CYLS IN LARGEST EXTENT
SRC001  HAS LESS THAN 050 CYLS IN LARGEST EXTENT
SRC002  HAS LESS THAN 050 CYLS IN LARGEST EXTENT