use strict ; use warnings ;
use Filesys::DfPortable ;
use Sys::Filesystem ();
my $fs = Sys::Filesystem->new();
my @filesystems = $fs->filesystems();
my %hs = () ; # the sorted hash
my %hns = () ; # the non-sorted hash
for my $filesystem ( @filesystems ) {
my $mount = $fs->mount_point($filesystem) ;
my $ref = dfportable("$mount", (1024*1024)); # Display output in 1MB blocks
if(defined($ref)) {
$hns {$mount} = $ref->{per} . '*' . $ref->{bused} . '*' . $ref->{blocks}
. '*' . $ref->{bavail} . '*' . $ref->{bfree} ;
$hs {$mount} = $ref->{per};
} #eof if
} #eof for
printf "%-15s %10s %10s %10s %10s %10s \n" , "Mount " , "Usage in % "
, "Used MB " , "Total MB " , "Available MB " , "Free MB " ;
print '========================================================================' . "\n" ;
foreach my $key (reverse sort { ($hs{$a} <=> $hs{$b}) } keys %hs) {
printf "%-15s %10d %10d %10d %10d %10d \n" , "$key" , split ('\*' , $hns{$key});
}
1 ;
__END__
=cut
Purpose:
OS independant mount points space usage
License: Free BSD
Requirements:
perl -MCPAN -e "install Filesys::DfPortable"
perl -MCPAN -e "install Sys::Filesystem"
VersionHistory:
1.0.0 -- 2013-12-23 15:28:07 -- ysg -- Initial creation with sorting
=pod
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!