#!/usr/local/bin/perl -w
use strict;
#
# A version of 'df' which produces the same output on any system
#
use Filesys::DiskFree;
#
# Create a df handle
#
my $df = new Filesys::DiskFree;
#
# Call the actual df command
#
$df->df();
my $disk;
#
# Output the information
#
my $percent;
foreach $disk(sort($df->disks)){
my $total=($df->used($disk)+$df->avail($disk));
$percent=0;
if($total != 0){
$percent=sprintf("%2.0f",($df->used($disk)/$total)*100);
}
write;
}
#
# Format for the header
#
format STDOUT_TOP =
Filesystem 1024-blocks Used Available Capacity Mounted on
.
#
# Format for each data item, notice the /1024's, all sizes are stored in bytes
# for portablity
#
format STDOUT =
@<<<<<<<<<<<<<<<<<< @>>>>>>> @>>>>>> @>>>>>>> @>>% @<<<<<<<<<<<<<<<<<<<<<<<
$df->device($disk), $df->total($disk)/1024, $df->used($disk)/1024,$df->avail($disk)/1024, $percent,$df->mount($disk)
.
syntax highlighted by Code2HTML, v. 0.9.1