sigar/bindings/perl/examples/df.pl

39 lines
749 B
Perl
Raw Normal View History

2004-06-22 06:37:04 +08:00
#!/usr/bin/perl
use strict;
use Sigar;
my $sigar = new Sigar;
my $fslist = $sigar->file_system_list;
print "Filesytem\tSize\tUsed\tAvail\tUse%\tMounted on\tType\n";
for my $fs (@$fslist) {
my $dirname = $fs->dir_name;
2004-07-22 04:04:31 +08:00
my $usage = $sigar->file_system_usage($dirname);
2004-06-22 06:37:04 +08:00
my $total = $usage->total;
my $used = $total - $usage->free;
my $avail = $usage->avail;
my $pct = $usage->use_percent * 100;
my $usePct;
if ($pct == 0) {
$usePct = "-"
}
else {
$usePct = $pct . '%';
}
print
$fs->dev_name . "\t" .
$total . "\t" .
$used . "\t" .
$avail . "\t" .
$usePct . "\t" .
$dirname . "\t" .
$fs->sys_type_name . "/" . $fs->type_name . "\n";
}