zabbix-agent-addons/zabbix_scripts/check_lvm_sudo
2014-11-07 14:47:30 +01:00

50 lines
980 B
Perl

#!/usr/bin/perl -w
use Linux::LVM;
Linux::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);