Fix #2210
This commit is contained in:
parent
cc5c7c5159
commit
f806155c90
|
@ -24,13 +24,12 @@ use base qw(centreon::plugins::templates::counter);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_health_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = sprintf("health current: %d%%, previous: %d%%", $self->{result_values}->{current}, $self->{result_values}->{previous});
|
||||
return $msg;
|
||||
return sprintf('health current: %d%%, previous: %d%%', $self->{result_values}->{current}, $self->{result_values}->{previous});
|
||||
}
|
||||
|
||||
sub custom_health_perfdata {
|
||||
|
@ -38,7 +37,6 @@ sub custom_health_perfdata {
|
|||
|
||||
foreach ('current', 'previous') {
|
||||
$self->{output}->perfdata_add(
|
||||
label => $_,
|
||||
nlabel => 'fabric.health.' . $_ . '.percentage',
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{dn} : undef,
|
||||
value => $self->{result_values}->{$_},
|
||||
|
@ -51,19 +49,18 @@ sub set_counters {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'fabric', type => 1, cb_prefix_output => 'prefix_fabric_output', message_multiple => 'all fabrics are ok' },
|
||||
{ name => 'fabric', type => 1, cb_prefix_output => 'prefix_fabric_output', message_multiple => 'all fabrics are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{fabric} = [
|
||||
{ label => 'health', threshold => 0, set => {
|
||||
{ label => 'health', type => 2, set => {
|
||||
key_values => [ { name => 'current' }, { name => 'previous' }, { name => 'dn' } ],
|
||||
closure_custom_calc => \&catalog_status_calc,
|
||||
closure_custom_output => $self->can('custom_health_output'),
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
closure_custom_perfdata => $self->can('custom_health_perfdata'),
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng,
|
||||
closure_custom_perfdata => $self->can('custom_health_perfdata')
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_fabric_output {
|
||||
|
@ -77,21 +74,12 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-health:s' => { name => 'warning_health' },
|
||||
'critical-health:s' => { name => 'critical_health' },
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_health', 'critical_health']);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ sub set_counters {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'nodes', type => 1, cb_prefix_output => 'prefix_nodes_output', message_multiple => 'All fabric nodes are ok' },
|
||||
{ name => 'nodes', type => 1, cb_prefix_output => 'prefix_nodes_output', message_multiple => 'All fabric nodes are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{nodes} = [
|
||||
|
@ -38,29 +38,26 @@ sub set_counters {
|
|||
key_values => [ { name => 'current' }, { name => 'dn' } ],
|
||||
output_template => 'current: %s %%', output_error_template => "current: %s %%",
|
||||
perfdatas => [
|
||||
{ label => 'health_current', value => 'current', template => '%d',
|
||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'dn' },
|
||||
],
|
||||
{ template => '%d', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'dn' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'health-minimum', nlabel => 'node.health.minimum.percentage', set => {
|
||||
key_values => [ { name => 'min' }, { name => 'dn' } ],
|
||||
output_template => 'min: %s %%', output_error_template => "min: %s %%",
|
||||
perfdatas => [
|
||||
{ label => 'health_min', value => 'min', template => '%d',
|
||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'dn' },
|
||||
],
|
||||
{ template => '%d', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'dn' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'health-average', nlabel => 'node.health.average.percentage', set => {
|
||||
key_values => [ { name => 'avg' }, { name => 'dn' } ],
|
||||
output_template => 'average: %s %%', output_error_template => "average %s %%",
|
||||
perfdatas => [
|
||||
{ label => 'health_avg', value => 'avg', template => '%d',
|
||||
unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'dn' },
|
||||
],
|
||||
{ template => '%d', unit => '%', min => 0, max => 100, label_extra_instance => 1, instance_use => 'dn' }
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -76,7 +73,7 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-node:s' => { name => 'filter_node' },
|
||||
'filter-node:s' => { name => 'filter_node' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -91,8 +88,8 @@ sub manage_selection {
|
|||
$node->{fabricNodeHealth5min}->{attributes}->{dn} =~ /^topology\/(.*)\/sys\/CDfabricNodeHealth5min$/;
|
||||
my $node_dn = $1;
|
||||
if (defined($self->{option_results}->{filter_node}) && $self->{option_results}->{filter_node} ne '' &&
|
||||
$node_dn =~ /$self->{option_results}->{filter_node}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $node_dn . "': no matching filter node '" . $node . "'", debug => 1);
|
||||
$node_dn !~ /$self->{option_results}->{filter_node}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $node_dn . "': no matching filter", debug => 1);
|
||||
next;
|
||||
}
|
||||
$self->{nodes}->{$node_dn} = {
|
||||
|
|
|
@ -24,13 +24,12 @@ use base qw(centreon::plugins::templates::counter);
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||
|
||||
sub custom_health_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $msg = sprintf("health current: %d%%, previous: %d%%", $self->{result_values}->{current}, $self->{result_values}->{previous});
|
||||
return $msg;
|
||||
return sprintf('health current: %d%%, previous: %d%%', $self->{result_values}->{current}, $self->{result_values}->{previous});
|
||||
}
|
||||
|
||||
sub custom_health_perfdata {
|
||||
|
@ -38,7 +37,6 @@ sub custom_health_perfdata {
|
|||
|
||||
foreach ('current', 'previous') {
|
||||
$self->{output}->perfdata_add(
|
||||
label => $_,
|
||||
nlabel => 'tenant.health.' . $_ . '.percentage',
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{dn} : undef,
|
||||
value => $self->{result_values}->{$_},
|
||||
|
@ -51,19 +49,18 @@ sub set_counters {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'tenant', type => 1, cb_prefix_output => 'prefix_tenant_output', message_multiple => 'All tenants are ok' },
|
||||
{ name => 'tenant', type => 1, cb_prefix_output => 'prefix_tenant_output', message_multiple => 'All tenants are ok' }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{tenant} = [
|
||||
{ label => 'health', threshold => 0, set => {
|
||||
{ label => 'health', type => 2, set => {
|
||||
key_values => [ { name => 'current' }, { name => 'previous' }, { name => 'dn' } ],
|
||||
closure_custom_calc => \&catalog_status_calc,
|
||||
closure_custom_output => $self->can('custom_health_output'),
|
||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
||||
closure_custom_threshold_check => \&catalog_status_threshold_ng,
|
||||
closure_custom_perfdata => $self->can('custom_health_perfdata')
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_tenant_output {
|
||||
|
@ -78,21 +75,12 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-tenant:s' => { name => 'filter_tenant' },
|
||||
'warning-health:s' => { name => 'warning_health' },
|
||||
'critical-health:s' => { name => 'critical_health' },
|
||||
'filter-tenant:s' => { name => 'filter_tenant' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_health', 'critical_health']);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -103,8 +91,8 @@ sub manage_selection {
|
|||
foreach my $object (@{$result->{imdata}}) {
|
||||
my $dn = $object->{fvTenant}->{attributes}->{name};
|
||||
if (defined($self->{option_results}->{filter_tenant}) && $self->{option_results}->{filter_tenant} ne '' &&
|
||||
$dn =~ /$self->{option_results}->{filter_tenant}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $dn . "': no matching filter ", debug => 1);
|
||||
$dn !~ /$self->{option_results}->{filter_tenant}/) {
|
||||
$self->{output}->output_add(long_msg => "skipping '" . $dn . "': no matching filter", debug => 1);
|
||||
next;
|
||||
}
|
||||
$self->{tenant}->{$dn} = {
|
||||
|
|
|
@ -30,13 +30,13 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$self->{version} = '0.1';
|
||||
%{ $self->{modes} } = (
|
||||
$self->{modes} = {
|
||||
'node' => 'network::cisco::aci::apic::restapi::mode::node',
|
||||
'tenant' => 'network::cisco::aci::apic::restapi::mode::tenant',
|
||||
'fabric' => 'network::cisco::aci::apic::restapi::mode::fabric',
|
||||
);
|
||||
'fabric' => 'network::cisco::aci::apic::restapi::mode::fabric'
|
||||
};
|
||||
|
||||
$self->{custom_modes}{api} = 'network::cisco::aci::apic::restapi::custom::api';
|
||||
$self->{custom_modes}->{api} = 'network::cisco::aci::apic::restapi::custom::api';
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue