Listing 4 Miles df report
#!/usr/bin/perl
#
# Name: Miles DF report (mi_df)
#
# Purpose: fancy df display
#
# Date: Jan 2001
#
# Required Parameters:
# -------------------------------------------------------------------------
# None.
#
# Optional Parameters:
# -------------------------------------------------------------------------
# None.
#
# Change History:
#
# Date Name Comments
# _________________________________________________________________________
#
$FILE="/tmp/df.$$";
`/usr/bin/df -k >$FILE`;
$COLUMNS=`stty -a | grep columns | cut -c 27-29`;
print "=" x $COLUMNS . "\n";
open (DF, $FILE);
while (defined ($_ = <DF> )){
($FS, $BLOCKS, $FSFREE, $FSUSED, $IUSED, $PIUSED, $MOUNT) = split;
$BLOCKS=~s/1024-blocks/Size (Mb)/;
$FSFREE=~s/Free/Free (Mb)/;
$FSUSED=~s/([0-9])\%/$1/;
$PIUSED=~s/([0-9])\%/$1/;
# note that I switch FS and MOUNT around
$MOUNT=~s/Mounted/Filesystem/;
$FS=~s/Filesystem/Other/;
if ($MOUNT eq "\/") {
$FS = "Root"
}
elsif ($FS=~/:/) {
$FS1 = "NFS from " . $FS; $FS=$FS1
}
else {
$FS=$MOUNT;
$FS =~ s/\///;
}
if ($BLOCKS ne "Size (Mb)") { $BLOCKS /= 1024 };
if ($FSFREE ne "Free (Mb)") { $FSFREE = int ($FSFREE /= 1024) };
if ($MOUNT=~"Filesystem") {
printf "%-25s %-9s %-9s %-9s %-9s %-11s\n",$MOUNT, $BLOCKS, $FSFREE, \
$FSUSED, $PIUSED, $FS;
print "=" x $COLUMNS . "\n" }
elsif (not $MOUNT=~"\/u\/" or $FS=~"NFS") {
printf "%-25s %-9d %-9d %-9s %-9s %-11s\n",$MOUNT, $BLOCKS, $FSFREE, \
$FSUSED, $PIUSED, $FS;
}
}
print "-" x $COLUMNS . "\n";
close (DF);
|