This commit is contained in:
garnier-quentin 2020-09-22 11:59:10 +02:00
parent 83cfe2a246
commit 894abc6418
1 changed files with 8 additions and 17 deletions

View File

@ -24,7 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
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 {
my ($self, %options) = @_;
@ -41,11 +41,11 @@ sub set_counters {
];
$self->{maps_counters}->{nodes} = [
{ label => 'node-status', threshold => 0, set => {
{ label => 'node-status', type => 2, critical_default => '%{status} !~ /ready/ || %{manager_status} !~ /reachable|-/', set => {
key_values => [ { name => 'status' }, { name => 'manager_status' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
}
];
@ -68,7 +68,7 @@ sub set_counters {
]
}
},
{ label => 'containers-running', set => {
{ label => 'containers-paused', set => {
key_values => [ { name => 'containers_paused' }, { name => 'display' } ],
output_template => 'Containers Paused : %s',
perfdatas => [
@ -86,20 +86,11 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'warning-node-status:s' => { name => 'warning_node_status', default => '' },
'critical-node-status:s' => { name => 'critical_node_status', default => '%{status} !~ /ready/ || %{manager_status} !~ /reachable|-/' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_node_status', 'critical_node_status']);
}
sub prefix_node_output {
my ($self, %options) = @_;
@ -108,11 +99,11 @@ sub prefix_node_output {
sub manage_selection {
my ($self, %options) = @_;
$self->{node} = {};
$self->{nodes} = {};
my $result = $options{custom}->api_list_nodes();
$self->{node} = {};
$self->{nodes} = {};
foreach my $node_name (keys %{$result}) {
$self->{node}->{$node_name} = {
display => $node_name,
@ -129,7 +120,7 @@ sub manage_selection {
};
}
}
if (scalar(keys %{$self->{node}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No node found.");
$self->{output}->option_exit();