mirror of
https://github.com/Cacti/cacti.git
synced 2026-12-04 22:23:28 +09:00
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/cacti/branches/0.8.7@5961 860744bd-22fc-0310-8c96-e9fe5004b5ca
44 lines
1.0 KiB
Perl
44 lines
1.0 KiB
Perl
#!/usr/bin/perl
|
|
|
|
if (($ARGV[0] ne "query") && ($ARGV[0] ne "get") && ($ARGV[0] ne "index") && ($ARGV[0] ne "num_indexes")) {
|
|
print "usage:\n\n";
|
|
print "./query_unix_partitions.pl index\n";
|
|
print "./query_unix_partitions.pl num_indexes\n";
|
|
print "./query_unix_partitions.pl query {device,mount,total,used,available,percent}\n";
|
|
print "./query_unix_partitions.pl get {device,mount,total,used,available,percent} DEVICE\n";
|
|
exit;
|
|
}
|
|
|
|
open(DF, "/bin/df -P -k|");
|
|
|
|
$count=0;
|
|
while (<DF>) {
|
|
#/dev/hda2 20157744 18553884 579860 97% /var
|
|
if (/^(\/\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)%\s+(\/\S*)$/) {
|
|
my %output = (
|
|
device => $1,
|
|
mount => $6,
|
|
total => $2,
|
|
used => $3,
|
|
available => $4,
|
|
percent => $5
|
|
);
|
|
|
|
if ($ARGV[0] eq "index") {
|
|
print "$1\n";
|
|
}elsif ($ARGV[0] eq "num_indexes") {
|
|
$count++;
|
|
}elsif (($ARGV[0] eq "get") && ($ARGV[2] eq $1)) {
|
|
print $output{$ARGV[1]};
|
|
}elsif ($ARGV[0] eq "query") {
|
|
print "$output{device}:$output{$ARGV[1]}\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
close(DF);
|
|
|
|
if ($ARGV[0] eq "num_indexes") {
|
|
print "$count\n";
|
|
}
|