Discover thin pools, and report thin pool allocation

This commit is contained in:
Daniel Berteaud 2014-11-07 14:47:30 +01:00
parent 54e4be8804
commit f83c0e60d1
2 changed files with 22 additions and 1 deletions

View File

@ -15,7 +15,7 @@ my $what = $ARGV[1];
sub usage {
print<<"EOF";
Usage: $0 <logical volume> [size|allocation|status]
Usage: $0 <logical volume> [size|allocation|allocation_pool_data|allocation_metadata|status]
EOF
}
@ -30,6 +30,16 @@ elsif ($what eq 'allocation'){
$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};
}

View File

@ -30,6 +30,17 @@ elsif ($what eq "snapshots"){
}
}
}
elsif ($what eq "thin_pools"){
foreach my $group (get_volume_group_list()){
my %lvs = get_logical_volume_information($group);
foreach my $lv (keys %lvs){
if (defined $lvs{$lv}->{allocated_pool_data}){
$lv = ($lv =~ m!^/dev/$group!) ? $lv : "/dev/$group/$lv";
push @{$json->{data}}, { "{#LVMTHINP}" => "$lv" };
}
}
}
}
elsif ($what eq "groups"){
foreach my $group (get_volume_group_list()){
push @{$json->{data}}, { "{#LVMGRP}" => $group };