04-02-2013 02:04 PM
We have a single OpenVMS V8.3-1H1 server running on HP rx2660 hardware in our environment.
All our other servers are Unix and Linux machines.
I'm trying to come up with a script for the VMS server that will display output similar to the Unix/Linux "df" command, which gives disk utilization.
On our Unix/Linux servers, output of the "df" command is as follows.
$ df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/vg00/lvol3 1.1G 445M 701M 39% /
/dev/vg00/lvol1 1.1G 407M 739M 36% /stand
/dev/vg01/lvxtra 2.0G 938M 1.1G 46% /xtra
/dev/vg00/lvol7 6.0G 4.5G 1.5G 75% /var
/dev/vg00/lvol6 8.0G 3.5G 4.5G 44% /usr
/dev/vg00/lvol5 1.0G 19M 997M 2% /tmp
/dev/vg00/lvol4 7.0G 5.5G 1.5G 79% /opt
/dev/vg01/lvhome 512M 18M 490M 4% /home
Could someone please provide some guidance on creating a VMS script that will report disk usage is this format.
That is, the device name, it's size, amount of space used, amount of space available (in GB and MB where appropriate), as well the usage percentage and volume label.
I'm familiar with the "show device /full /units=bytes" command and I'm guessing the output of this command could be used to parse out selected data and generate a report similar to "df" but I'm not certain how to go about it.
Again, any assistance on this would be really helpful.
Thanks in advance.
04-02-2013 02:35 PM
If you want to do it in DCL you'll need lexical function F$GETDVI (...). If you want it to run faster then write it in some language, even Macro, and use SYS$GETDVI.
Look up the help on both the above to see the details.
04-02-2013 04:59 PM - edited 04-02-2013 05:01 PM
Here's a rough cut. DCL is hopeless with decimal arithmetic, so getting the decimals in the sizes is a problem. This code kind of works, but fractional parts are truncated rather than rounded.
If the spacing is critical, you may need to play with the formatting (what does the unix command do if the size evaluates to between 1000 and 1024?)
$! Filesystem Size Used Avail Capacity Mounted on $! 12345678901234567890123456789012345678901234567890
12345678901234567890 $ fmt="!24AS!7AS!7AS!7AS !3AS" $ WRITE SYS$OUTPUT "Filesystem Size Used Avail Capacity Mounted on" $ DiskLoop: disk=F$DEVICE("*''p1'*","DISK")-"_"-":" $ IF disk.NES."" $ THEN $! Skip devices that are not mounted or are shadow set members $ IF F$GETDVI(disk,"MNT").AND..NOT.F$GETDVI(disk,"SHDW_ MEMBER") $ THEN $ MaxBlock=F$GETDVI(disk,"MAXBLOCK")/2 ! Convert to KB $ FreeBlocks=F$GETDVI(disk,"FREEBLOCKS")/2 $ Avail=MaxBlock-FreeBlocks $ Percent=F$FAO("!2UL%",FreeBlocks/(MaxBlock/100)) $ s=MaxBlock $ GOSUB HumanSize $ MaxBlock=v $ s=FreeBlocks $ GOSUB HumanSize $ FreeBlocks=v $ s=Avail $ GOSUB HumanSize $ Avail=v $ WRITE SYS$OUTPUT F$FAO(fmt,disk,MaxBlock,FreeBlocks,Avail,Percent) $ ENDIF $ GOTO DiskLoop $ ENDIF $ EXIT $ $ HumanSize: $ i=0 $ Prefix="KMGTPEZY" $ dec="" $ RangeLoop: $ IF s.LT.1024 $ THEN $ v=F$FAO("!4UL!AS!AS",s,dec,F$EXTRACT(i,1,Prefix)) $ RETURN $ ENDIF $ m=s/1024 $ dec=F$FAO(".!1UL",(s-m*1024)/(1024/10)) $ s=m $ i=i+1 $ GOTO RangeLoop
$ @df Filesystem Size Used Avail Capacity Mounted on DSA30 15.0G 7.9G 7.0G 53% DSA31 15.0G 2.0G 12.9G 13% DSA32 15.0G 14.9G 103.8M 99% DSA42 30.0G 14.8G 15.2G 49% DSA44 30.0G 20.9G 9.0G 69% DSA45 75.0G 62.9G 12.0G 83% DSA46 100.0G 99.7G 269.8M 99% DSA100 20.0G 4.9G 15.0G 24%
04-03-2013 12:45 AM
I know, you asked for a script, and I kown it's not the wheel, but there is already some code in GNV. You may want to use the supplied executable or checkout the source code. Getting/using the executable (for Alpha, I don't have access to an I64 system) can be as easy as fetching the PCSI file and:
$ prod extr file gnv/source=DSA110:[ALPHA.OPENVMS.GNV.V30-1]/sel=df
Performing product kit validation of signed kits ...
%PCSI-I-VALPASSED, validation of DSA110:[ALPHA.OPENVMS.GNV.V30-1]DEC-AXPVMS-GNV$
The following product has been selected:
DEC AXPVMS GNV V3.0-1 Layered Product
Do you want to continue? [YES]
Portion done: 0%...100%
$ mc df -h
Filesystem Size Used Avail Use% Mounted on
_DSA110: 20G 20G 70M 100% _DSA110:
_DSA115: 20G 20G 179M 100% _DSA115:
_DSA153: 8.5G 6.7G 1.9G 79% _DSA153:
_DSA200: 4.0G 2.2G 1.9G 53% _DSA200: