bdfmegs – a better bdf

df and bdf history

In HP-UX, the df command has a particularly obnoxious format so a better df (bdf) command is available. However, bdf was written a long time ago when long lines of text (more than 80 characters) was a problem and thus, bdf splits the sourcefile for the mount point away from the numbers. And again showing its age, bdf does not align large and small numbers and the units of measure are kilobytes (KB), a rather tiny metric when dealing with gigabytes and terabytes. Indeed, many system administrators have written scripts to watch disk space using bdf and have run into several difficulties, especially with split lines.

bdfmegs

I wrote bdfmegs in 1997 to join the split bdf lines together and to switch from KB to MB. It is a script to take the information from bdf (and other tools) and make the output easier to parse in disk space monitors. It went through several redesigns, from inefficient calls to bdf, to temporary files and now using large variables to hold data which requires a large amount of system overhead to collect. To make it easier to parse in scripts, a -q will delete header and trailer information as well as remove any screen enhancements.

With version 6.0, bdfmegs now reports the version number for NFS as well as the LVM version number. Previous enhancements added snapshot filesystems, 1000/1024 divisor capability, and sorting by columns. Here are some examples:

# bdf Filesystem kbytes used avail %used Mounted on /dev/vg00/lvol3 1048576 148824 892776 14% / /dev/vg00/lvol1 505392 46072 408776 10% /stand /dev/vg00/lvol8 6160384 1048408 5075424 17% /var /dev/vg00/lvol7 4194304 1392552 2779904 33% /usr /dev/vg00/lvol6 1048576 270168 772384 26% /tmp /dev/vgbig/lvol1 1002504192 666993512 332906232 67% /support /dev/vg00/lvol5 6160384 2695312 3438056 44% /opt /dev/vg00/lvol4 131072 2664 127408 2% /home atl1:/var/tmp/Packages 512000000 217821336 275792960 44% /mnt3 

# bdfmegs

File-System Mbytes Used Avail %Used Mounted on
/dev/vg00/lvol3 1048 148 892 14% /
/dev/vg00/lvol1 505 46 408 10% /stand
/dev/vg00/lvol8 6160 1048 5075 17% /var
/dev/vg00/lvol7 4194 1392 2779 33% /usr
/dev/vg00/lvol6 1048 270 772 26% /tmp
/dev/vgbig/lvol1 1002.5g 667.0g 332.9g 67% /support
/dev/vg00/lvol5 6160 2695 3438 44% /opt
/dev/vg00/lvol4 131 2 127 2% /home
atl1:/var/tmp/Packages 512.0g 217.8g 275.8g 44% /mnt3

Additionally, bdfmegs can sort by column (such as column 4 for available space):

# bdfmegs -c4
File-System Mbytes Used Avail %Used Mounted on
/dev/vg00/lvol4 131 2 127 2% /home
/dev/vg00/lvol1 505 46 408 10% /stand
/dev/vg00/lvol6 1048 270 772 26% /tmp
/dev/vg00/lvol3 1048 148 892 14% /
/dev/vg00/lvol7 4194 1392 2779 33% /usr
/dev/vg00/lvol5 6160 2695 3438 44% /opt
/dev/vg00/lvol8 6160 1048 5075 17% /var
atl1:/var/tmp/Packages 512.0g 217.8g 275.8g 44% /mnt3
/dev/vgbig/lvol1 1002.5g 667.0g 332.9g 67% /support

Or alphabetically sort by mountpoint:

# bdfmegs -c6
File-System Mbytes Used Avail %Used Mounted on
/dev/vg00/lvol3 1048 148 892 14% /
/dev/vg00/lvol4 131 2 127 2% /home
atl1:/var/tmp/Packages 512.0g 217.8g 275.8g 44% /mnt3
/dev/vg00/lvol5 6160 2695 3438 44% /opt
/dev/vg00/lvol1 505 46 408 10% /stand
/dev/vgbig/lvol1 1002.5g 667.0g 332.9g 67% /support
/dev/vg00/lvol6 1048 270 772 26% /tmp
/dev/vg00/lvol7 4194 1392 2779 33% /usr
/dev/vg00/lvol8 6160 1048 5075 17% /var

bdfmegs supports HP-UX 10.01 through 11.31 including snapMemFSautofscifs and DevFS. For root users, the -v option gives additional details about each filesystem.

# bdfmegs -v File-System Mbytes Used Avail %Used Type Vr Lrg VGv Mounted on /dev/vg00/lvol3 1048 439 604 42% vxfs 6 yes 1.0 / /dev/vg00/lvol8 8912 3502 5370 39% vxfs 6 yes 1.0 /var /dev/vg00/lvol7 4554 3316 1228 73% vxfs 6 yes 1.0 /usr /dev/vg00/lvol4 524 199 322 38% vxfs 6 yes 1.0 /tmp /dev/vg00/lvol1 1835 347 1476 19% vxfs 5 no 1.0 /stand /dev/vg00/lvol6 8192 7389 796 90% vxfs 6 yes 1.0 /opt /dev/vg00/lvol5 131 7 122 6% vxfs 6 yes 1.0 /home atl1:/var/tmp/Packages 512.0g 217.8g 275.8g 44% nfs 3 -- n/a /mnt3 memfs 102 0 102 0% memfs na -- n/a /mnt-memfs /dev/vg2.1/lvol2.1 102.4g 42 96.0g 0% vxfs 6 yes 2.1 /mnt2.1 /dev/vgbig/lvol1 1074.5g 526 1006.8g 0% vxfs 7 yes 1.0 /mnt4 

Another feature is that bdfmegs will never split a line no matter the length of the source lvol name. Here are all the options (bdfmegs -?):

# bdfmegs -?

Usage: bdfmegs [ -cghlNPpqstuVv ] [ <file(s) or dir(s)> ]
where:
-c # = Sort on column #
-d = Toggle divisor (1000 or 1024, current=1000)
-e = enhancement for percentage and errors
d=dim h=halfbright i=inverse u=underline b=blink
-g = show gigabytes, otherwise megabytes
-h = Usage
-l = local (no NFS)
-M <mountpoints> = skip (grep -v) mountpoints
-N <VGnames> = skip one or more volume groups
Repeat -N or use commas: -N vg10,vg24
-p ## = highlight % -ge ##
-P ## = show only % -ge ##
-q = suppress header line and no char enhancements
-s = summarize total, used and available
-t <fs> = filesystem: (hfs vxfs nfs cdfs cifs autofs DevFS memfs)
-u = usage
-v = verbose (FStype, FSversion, largefiles, VGversion)
(VG version needs read permission for devicefile)
-V <VGname> = select one or more volume groups
Repeat -V or use commas: -V vg00,vg01

File(s) or dirpath(s) may be specified to reduce the output of bdfmegs:

     bdfmegs -vg /usr/contrib/bin . .. /var/tmp

If bdfmegs is run as bdfgigs (ie, a link), then -g is default.

                                          (bdfmegs ver 6.1_Nov2011)

To get the latest copy of the bdfmegs script, go to:
ftp://ftp.sourcedirect.com/pub/tools/PowerTools/

– See more at: http://serviceitdirect.com/blog/bdfmegs-better-bdf#sthash.OPOo61hp.dpuf


Tags: