mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-28 16:14:21 +02:00
add filter-counters-block option
This commit is contained in:
parent
178ca521b6
commit
8f4930e364
@ -120,14 +120,18 @@ sub new {
|
|||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
|
'filter-counters-block:s' => { name => 'filter_counters_block' },
|
||||||
'filter-counters:s' => { name => 'filter_counters' },
|
'filter-counters:s' => { name => 'filter_counters' },
|
||||||
'display-ok-counters:s' => { name => 'display_ok_counters' },
|
'display-ok-counters:s' => { name => 'display_ok_counters' },
|
||||||
'list-counters' => { name => 'list_counters' },
|
'list-counters' => { name => 'list_counters' },
|
||||||
});
|
});
|
||||||
$self->{statefile_value} = undef;
|
$self->{statefile_value} = undef;
|
||||||
if (defined($options{statefile}) && $options{statefile}) {
|
if (defined($options{statefile}) && $options{statefile}) {
|
||||||
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'centreon::plugins::statefile',
|
centreon::plugins::misc::mymodule_load(
|
||||||
error_msg => "Cannot load module 'centreon::plugins::statefile'.");
|
output => $self->{output},
|
||||||
|
module => 'centreon::plugins::statefile',
|
||||||
|
error_msg => "Cannot load module 'centreon::plugins::statefile'."
|
||||||
|
);
|
||||||
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,6 +208,8 @@ sub check_options {
|
|||||||
sub run_global {
|
sub run_global {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return undef if (defined($self->{option_results}->{filter_counters_block}) && $self->{option_results}->{filter_counters_block} ne ''
|
||||||
|
&& $options{config}->{name} =~ /$self->{option_results}->{filter_counters_block}/);
|
||||||
return undef if (defined($options{config}->{cb_init}) && $self->call_object_callback(method_name => $options{config}->{cb_init}) == 1);
|
return undef if (defined($options{config}->{cb_init}) && $self->call_object_callback(method_name => $options{config}->{cb_init}) == 1);
|
||||||
my $resume = defined($options{resume}) && $options{resume} == 1 ? 1 : 0;
|
my $resume = defined($options{resume}) && $options{resume} == 1 ? 1 : 0;
|
||||||
# Can be set when it comes from type 3 counters
|
# Can be set when it comes from type 3 counters
|
||||||
@ -287,6 +293,8 @@ sub run_global {
|
|||||||
sub run_instances {
|
sub run_instances {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return undef if (defined($self->{option_results}->{filter_counters_block}) && $self->{option_results}->{filter_counters_block} ne ''
|
||||||
|
&& $options{config}->{name} =~ /$self->{option_results}->{filter_counters_block}/);
|
||||||
return undef if (defined($options{config}->{cb_init}) && $self->call_object_callback(method_name => $options{config}->{cb_init}) == 1);
|
return undef if (defined($options{config}->{cb_init}) && $self->call_object_callback(method_name => $options{config}->{cb_init}) == 1);
|
||||||
my $cb_init_counters = $self->get_callback(method_name => $options{config}->{cb_init_counters});
|
my $cb_init_counters = $self->get_callback(method_name => $options{config}->{cb_init_counters});
|
||||||
my $display_status_lo = defined($options{display_status_long_output}) && $options{display_status_long_output} == 1 ? 1 : 0;
|
my $display_status_lo = defined($options{display_status_long_output}) && $options{display_status_long_output} == 1 ? 1 : 0;
|
||||||
@ -449,6 +457,8 @@ sub run_group {
|
|||||||
sub run_multiple_instances {
|
sub run_multiple_instances {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return undef if (defined($self->{option_results}->{filter_counters_block}) && $self->{option_results}->{filter_counters_block} ne ''
|
||||||
|
&& $options{config}->{name} =~ /$self->{option_results}->{filter_counters_block}/);
|
||||||
return undef if (defined($options{config}->{cb_init}) && $self->call_object_callback(method_name => $options{config}->{cb_init}) == 1);
|
return undef if (defined($options{config}->{cb_init}) && $self->call_object_callback(method_name => $options{config}->{cb_init}) == 1);
|
||||||
my $use_new_perfdata = $self->{output}->use_new_perfdata();
|
my $use_new_perfdata = $self->{output}->use_new_perfdata();
|
||||||
my $multiple_parent = defined($options{multiple_parent}) && $options{multiple_parent} == 1 ? $options{multiple_parent} : 0;
|
my $multiple_parent = defined($options{multiple_parent}) && $options{multiple_parent} == 1 ? $options{multiple_parent} : 0;
|
||||||
@ -569,8 +579,12 @@ sub run_multiple {
|
|||||||
|
|
||||||
foreach my $instance (sort keys %{$self->{$options{config}->{name}}}) {
|
foreach my $instance (sort keys %{$self->{$options{config}->{name}}}) {
|
||||||
if (defined($options{config}->{cb_long_output})) {
|
if (defined($options{config}->{cb_long_output})) {
|
||||||
$self->{output}->output_add(long_msg => $self->call_object_callback(method_name => $options{config}->{cb_long_output},
|
$self->{output}->output_add(
|
||||||
instance_value => $self->{$options{config}->{name}}->{$instance}));
|
long_msg => $self->call_object_callback(
|
||||||
|
method_name => $options{config}->{cb_long_output},
|
||||||
|
instance_value => $self->{$options{config}->{name}}->{$instance}
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{prefix_multiple_output} = '';
|
$self->{prefix_multiple_output} = '';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user