/usr/share/doc/libsys-statistics-linux-perl/examples/diskusage.pl is in libsys-statistics-linux-perl 0.66-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #!/usr/bin/perl
use strict;
use warnings;
use Sys::Statistics::Linux;
use Sys::Statistics::Linux::DiskUsage;
$Sys::Statistics::Linux::DiskUsage::DF_CMD = 'df -hP';
my $sys = Sys::Statistics::Linux->new(diskusage => 1);
my $stat = $sys->get;
# $stat->diskusage returns the first level keys of the
# statistic hash as a array. The first level keys are
# the disk names.
foreach my $disk ( $stat->diskusage ) { # Gimme the disk names
print "Statistics for disk $disk:\n";
# $stat->diskusage($disk) returns the seconds level keys of
# the statistics. The second level keys are the statistic keys
# for the passed disk.
foreach my $key ( sort $stat->diskusage($disk) ) { # Gimme the statistic keys
# $stat->diskusage($disk, $key) returns the value for the passed
# disk and key.
printf " %-20s %s\n", $key, $stat->diskusage($disk, $key);
}
}
|