|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
use Zabbix::Agent::Addons::LVM;
|
|
|
|
|
|
|
|
Zabbix::Agent::Addons::LVM->units(B);
|
|
|
|
|
|
|
|
if (@ARGV < 2){
|
|
|
|
usage();
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
my $vol = $ARGV[0];
|
|
|
|
my $what = $ARGV[1];
|
|
|
|
|
|
|
|
sub usage {
|
|
|
|
print<<"EOF";
|
|
|
|
|
|
|
|
Usage: $0 <logical volume> [size|allocation|allocation_pool_data|allocation_metadata|status]
|
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
my %info = get_lv_info($vol);
|
|
|
|
|
|
|
|
if ($what eq 'size'){
|
|
|
|
print $info{size};
|
|
|
|
}
|
|
|
|
elsif ($what eq 'allocation'){
|
|
|
|
my $ret = (defined $info{allocated_to_snapshot}) ? $info{allocated_to_snapshot} : "ZBX_NOTSUPPORTED";
|
|
|
|
$ret =~ s/,/\./;
|
|
|
|
print $ret;
|
|
|
|
}
|
|
|
|
elsif ($what eq 'allocation_pool_data'){
|
|
|
|
my $ret = (defined $info{allocated_pool_data}) ? $info{allocated_pool_data} : "ZBX_NOTSUPPORTED";
|
|
|
|
$ret =~ s/,/\./;
|
|
|
|
print $ret;
|
|
|
|
}
|
|
|
|
elsif ($what eq 'allocation_metadata'){
|
|
|
|
my $ret = (defined $info{allocated_meta_data}) ? $info{allocated_meta_data} : "ZBX_NOTSUPPORTED";
|
|
|
|
$ret =~ s/,/\./;
|
|
|
|
print $ret;
|
|
|
|
}
|
|
|
|
elsif ($what eq 'status'){
|
|
|
|
print $info{status};
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
exit(0);
|