From 6804c405631ed07544cf9897cbbd3207a6f4550e Mon Sep 17 00:00:00 2001 From: UrBnW <40244829+UrBnW@users.noreply.github.com> Date: Wed, 16 Jun 2021 13:41:09 +0200 Subject: [PATCH] enh(3cx): add --filter-category option (#2879) --- .../apps/voip/3cx/restapi/mode/system.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/centreon-plugins/apps/voip/3cx/restapi/mode/system.pm b/centreon-plugins/apps/voip/3cx/restapi/mode/system.pm index 7e8f6ca3f..dd121de30 100644 --- a/centreon-plugins/apps/voip/3cx/restapi/mode/system.pm +++ b/centreon-plugins/apps/voip/3cx/restapi/mode/system.pm @@ -87,6 +87,7 @@ sub new { bless $self, $class; $options{options}->add_options(arguments => { + 'filter-category:s' => { name => 'filter_category' } }); return $self; @@ -121,9 +122,18 @@ sub manage_selection { service => 'HasUnregisteredSystemExtensions', error => $system->{HasUnregisteredSystemExtensions} ? 'true' : 'false', }; + my $updates = 0; + foreach my $category (@$update) { + if (defined($self->{option_results}->{filter_category}) && $self->{option_results}->{filter_category} ne '' && + $item->{Category} !~ /$self->{option_results}->{filter_category}/) { + $self->{output}->output_add(long_msg => "skipping update '" . $item->{Category} . "': no matching filter.", debug => 1); + next; + } + $updates++; + } $self->{service}->{HasUpdatesAvailable} = { service => 'HasUpdatesAvailable', - error => scalar(@$update) ? 'true' : 'false', + error => $updates ? 'true' : 'false', }; $self->{global} = { @@ -142,6 +152,10 @@ Check system health =over 8 +=item B<--filter-category> + +Filter updates' category. + =item B<--unknown-status> Set unknown threshold for status.