From f83c0e60d18cdd5d75a04ba1067669e9721d1bf3 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 7 Nov 2014 14:47:30 +0100 Subject: [PATCH] Discover thin pools, and report thin pool allocation --- zabbix_scripts/check_lvm_sudo | 12 +++++++++++- zabbix_scripts/disco_lvm_sudo | 11 +++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/zabbix_scripts/check_lvm_sudo b/zabbix_scripts/check_lvm_sudo index 3dcfe74..c01e117 100644 --- a/zabbix_scripts/check_lvm_sudo +++ b/zabbix_scripts/check_lvm_sudo @@ -15,7 +15,7 @@ my $what = $ARGV[1]; sub usage { print<<"EOF"; -Usage: $0 [size|allocation|status] +Usage: $0 [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}; } diff --git a/zabbix_scripts/disco_lvm_sudo b/zabbix_scripts/disco_lvm_sudo index 4bcf3f8..c9192d1 100644 --- a/zabbix_scripts/disco_lvm_sudo +++ b/zabbix_scripts/disco_lvm_sudo @@ -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 };