enhance netapp ontap rest api volumes

This commit is contained in:
garnier-quentin 2020-12-21 11:01:55 +01:00
parent b8de1d26cc
commit 4a7e0a0eab
4 changed files with 21 additions and 61 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);
use Digest::MD5 qw(md5_hex);
sub custom_status_output {
@ -121,11 +121,11 @@ sub set_counters {
];
$self->{maps_counters}->{nodes} = [
{ label => 'node-status', threshold => 0, set => {
{ label => 'node-status', type => 2, critical_default => '%{state} ne "online"', set => {
key_values => [ { name => 'state' }, { name => 'link_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
}
}
];
@ -136,22 +136,12 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
'unknown-node-status:s' => { name => 'unknown_node_status', default => '' },
'warning-node-status:s' => { name => 'warning_node_status', default => '' },
'critical-node-status:s' => { name => 'critical_node_status', default => '%{state} ne "online"' }
$options{options}->add_options(arguments => {
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_node_status', 'critical_node_status', 'unknown_node_status']);
}
sub manage_selection {
my ($self, %options) = @_;

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) = @_;
@ -50,11 +50,11 @@ sub set_counters {
];
$self->{maps_counters}->{luns} = [
{ label => 'status', threshold => 0, set => {
{ label => 'status', type => 2, critical_default => '%{state} !~ /online/i', set => {
key_values => [ { name => 'state' }, { name => 'container_state' }, { 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
}
}
];
@ -66,22 +66,12 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{state} !~ /online/i' }
'filter-name:s' => { name => 'filter_name' }
});
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 {
my ($self, %options) = @_;

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) = @_;
@ -51,11 +51,11 @@ sub set_counters {
];
$self->{maps_counters}->{snapmirrors} = [
{ label => 'status', threshold => 0, set => {
{ label => 'status', type => 2, critical_default => '%{healthy} ne "true" or %{state} eq "broken_off"', set => {
key_values => [ { name => 'healthy' }, { name => 'state' }, { name => 'transfer_state' }, { 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
}
}
];
@ -67,22 +67,12 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{healthy} ne "true" or %{state} eq "broken_off"' }
'filter-name:s' => { name => 'filter_name' }
});
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 {
my ($self, %options) = @_;

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) = @_;
@ -60,11 +60,11 @@ sub set_counters {
];
$self->{maps_counters}->{volumes} = [
{ label => 'status', threshold => 0, set => {
{ label => 'status', type => 2, critical_default => '%{state} !~ /online/i', set => {
key_values => [ { name => 'state' }, { 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
}
},
{ label => 'usage', nlabel => 'volume.space.usage.bytes', set => {
@ -86,8 +86,8 @@ sub set_counters {
}
},
{ label => 'usage-prct', nlabel => 'volume.space.usage.percentage', display_ok => 0, set => {
key_values => [ { name => 'prct_used_space' }, { name => 'display' } ],
output_template => 'space used: %.2f %%',
key_values => [ { name => 'prct_used_space' }, { name => 'used_space' }, { name => 'free_space' }, { name => 'prct_free_space' }, { name => 'total_space' }, { name => 'display' }, ],
closure_custom_output => $self->can('custom_usage_output'),
perfdatas => [
{ template => '%.2f', min => 0, max => 100,
unit => '%', label_extra_instance => 1 }
@ -153,22 +153,12 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'filter-name:s' => { name => 'filter_name' },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{state} !~ /online/i' }
'filter-name:s' => { name => 'filter_name' }
});
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 {
my ($self, %options) = @_;
@ -189,8 +179,8 @@ sub manage_selection {
total_space => $_->{space}->{size},
used_space => $_->{space}->{used},
free_space => $_->{space}->{available},
prct_used_space => $_->{space}->{used} * 100 / $_->{space}->{size},
prct_free_space => $_->{space}->{available} * 100 / $_->{space}->{size},
prct_used_space => (defined($_->{space}->{size}) && $_->{space}->{size} > 0) ? $_->{space}->{used} * 100 / $_->{space}->{size} : undef,
prct_free_space => (defined($_->{space}->{size}) && $_->{space}->{size} > 0) ? $_->{space}->{available} * 100 / $_->{space}->{size} : undef,
read => $_->{metric}->{throughput}->{read},
write => $_->{metric}->{throughput}->{write},
@ -200,7 +190,7 @@ sub manage_selection {
write_latency => $_->{metric}->{latency}->{write}
};
}
if (scalar(keys %{$self->{volumes}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No volume found");
$self->{output}->option_exit();