(plugin) os::aix::local - mode lvsync fix --filter-mount option (#3950)

This commit is contained in:
qgarnier 2022-10-03 09:51:52 +02:00 committed by GitHub
parent f3d22e60fb
commit 6efd1f30ab
1 changed files with 7 additions and 17 deletions

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict; use strict;
use warnings; use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold); use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_status_output { sub custom_status_output {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -56,7 +56,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{lvs} = [ $self->{maps_counters}->{lvs} = [
{ label => 'status', threshold => 0, set => { { label => 'status', type => 2, critical_default => '%{state} =~ /stale/i', set => {
key_values => [ key_values => [
{ name => 'state' }, { name => 'mount' }, { name => 'state' }, { name => 'mount' },
{ name => 'lv' }, { name => 'pp' }, { name => 'lv' }, { name => 'pp' },
@ -65,7 +65,7 @@ sub set_counters {
], ],
closure_custom_output => $self->can('custom_status_output'), closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; }, closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold closure_custom_threshold_check => \&catalog_status_threshold_ng
} }
} }
]; ];
@ -77,23 +77,13 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
'filter-type:s' => { name => 'filter_type' }, 'filter-type:s' => { name => 'filter_type' },
'unknown-status:s' => { name => 'unknown_status', default => '' }, 'filter-mount:s' => { name => 'filter_mount' }
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{state} =~ /stale/i' },
}); });
$self->{result} = {};
return $self; return $self;
} }
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']);
}
sub manage_selection { sub manage_selection {
my ($self, %options) = @_; my ($self, %options) = @_;
@ -110,12 +100,12 @@ sub manage_selection {
foreach my $line (@lines) { foreach my $line (@lines) {
next if ($line !~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*)/); next if ($line !~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*)/);
my ($lv, $type, $lp, $pp, $pv, $lvstate, $mount) = ($1, $2, $3, $4, $5, $6, $7); my ($lv, $type, $lp, $pp, $pv, $lvstate, $mount) = ($1, $2, $3, $4, $5, $6, $7);
next if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' && next if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' &&
$type !~ /$self->{option_results}->{filter_type}/); $type !~ /$self->{option_results}->{filter_type}/);
next if (defined($self->{option_results}->{filter_mount}) && $self->{option_results}->{filter_mount} ne '' && next if (defined($self->{option_results}->{filter_mount}) && $self->{option_results}->{filter_mount} ne '' &&
$mount !~ /$self->{option_results}->{filter_mount}/); $mount !~ /$self->{option_results}->{filter_mount}/);
$self->{lvs}->{$mount} = { $self->{lvs}->{$mount} = {
lv => $lv, lv => $lv,
mount => $mount, mount => $mount,