centreon-plugins/storage/emc/xtremio/restapi/mode/ssdiops.pm

179 lines
5.7 KiB
Perl
Raw Normal View History

2015-09-14 11:27:37 +02:00
#
2019-01-09 09:57:11 +01:00
# Copyright 2019 Centreon (http://www.centreon.com/)
2015-09-14 11:27:37 +02:00
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package storage::emc::xtremio::restapi::mode::ssdiops;
2019-04-06 20:51:37 +02:00
use base qw(centreon::plugins::templates::counter);
2015-09-14 11:27:37 +02:00
use strict;
use warnings;
2015-09-18 15:23:27 +02:00
2019-04-06 20:51:37 +02:00
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'ssd', type => 1, cb_prefix_output => 'prefix_ssd_output', message_multiple => 'All SSDs usages are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'total', set => {
key_values => [ { name => 'total' } ],
output_template => 'Total : %s iops',
perfdatas => [
{ label => 'total', value => 'total_absolute', template => '%s',
min => 0, unit => 'iops' },
],
}
},
{ label => 'total-read', set => {
key_values => [ { name => 'total_read' } ],
output_template => 'Total read : %s iops',
perfdatas => [
{ label => 'total_read', value => 'total_read_absolute', template => '%s',
min => 0, unit => 'iops' },
],
}
},
{ label => 'total-write', set => {
key_values => [ { name => 'total_write' } ],
output_template => 'Total write : %s iops',
perfdatas => [
{ label => 'total_write', value => 'total_write_absolute', template => '%s',
min => 0, unit => 'iops' },
],
}
},
];
$self->{maps_counters}->{ssd} = [
{ label => 'global', set => {
2015-09-18 15:23:27 +02:00
key_values => [ { name => 'global_iops' }, { name => 'display' }, ],
2019-04-06 20:51:37 +02:00
output_template => 'Global : %s iops',
2015-09-18 15:23:27 +02:00
perfdatas => [
2019-04-06 20:51:37 +02:00
{ label => 'global', value => 'global_iops_absolute', template => '%s',
2015-09-18 15:34:08 +02:00
min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display_absolute' },
2015-09-18 15:23:27 +02:00
],
}
},
2019-04-06 20:51:37 +02:00
{ label => 'read', set => {
2015-09-18 15:23:27 +02:00
key_values => [ { name => 'read_iops' }, { name => 'display' }, ],
2019-04-06 20:51:37 +02:00
output_template => 'Read : %s iops',
2015-09-18 15:23:27 +02:00
perfdatas => [
2019-04-06 20:51:37 +02:00
{ label => 'read', value => 'read_iops_absolute', template => '%s',
2015-09-18 15:34:08 +02:00
min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display_absolute' },
2015-09-18 15:23:27 +02:00
],
}
},
2019-04-06 20:51:37 +02:00
{ label => 'write', set => {
2015-09-18 15:23:27 +02:00
key_values => [ { name => 'write_iops' }, { name => 'display' }, ],
2019-04-06 20:51:37 +02:00
output_template => 'Write : %s iopss',
2015-09-18 15:23:27 +02:00
perfdatas => [
2019-04-06 20:51:37 +02:00
{ label => 'write', value => 'write_iops_absolute', template => '%s',
2015-09-18 15:34:08 +02:00
min => 0, unit => 'iops', label_extra_instance => 1, instance_use => 'display_absolute' },
2015-09-18 15:23:27 +02:00
],
}
},
2019-04-06 20:51:37 +02:00
];
}
2015-09-14 11:27:37 +02:00
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
2015-09-18 15:23:27 +02:00
2019-04-06 20:51:37 +02:00
$options{options}->add_options(arguments => {
"filter-name:s" => { name => 'filter_name' },
});
2015-09-14 11:27:37 +02:00
2019-04-06 20:51:37 +02:00
return $self;
2015-09-14 11:27:37 +02:00
}
2019-04-06 20:51:37 +02:00
sub prefix_ssd_output {
2015-09-14 11:27:37 +02:00
my ($self, %options) = @_;
2015-09-18 15:23:27 +02:00
2019-04-06 20:51:37 +02:00
return "SSD '" . $options{instance_value}->{display} . "' Usage ";
2015-09-14 11:27:37 +02:00
}
2015-09-18 15:23:27 +02:00
sub manage_selection {
2015-09-14 11:27:37 +02:00
my ($self, %options) = @_;
2015-09-18 15:23:27 +02:00
my $urlbase = '/api/json/types/';
2019-04-06 20:51:37 +02:00
my @items = $options{custom}->get_items(
url => $urlbase,
obj => 'ssds'
);
$self->{ssd} = {};
$self->{global} = { total => 0, total_read => 0, total_write => 0 };
2015-09-18 15:23:27 +02:00
foreach my $item (@items) {
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$item !~ /$self->{option_results}->{filter_name}/) {
2019-04-06 20:51:37 +02:00
$self->{output}->output_add(long_msg => "skipping '" . $item . "': no matching name.", debug => 1);
2015-09-18 15:23:27 +02:00
next;
2015-09-14 11:27:37 +02:00
}
2015-09-18 15:23:27 +02:00
2019-04-06 20:51:37 +02:00
my $details = $options{custom}->get_details(
url => $urlbase,
obj => 'ssds',
name => $item
);
$self->{global}->{total} += $details->{iops};
$self->{global}->{total_read} += $details->{'rd-iops'};
$self->{global}->{total_write} += $details->{'wr-iops'};
$self->{ssd}->{$item} = {
display => $item,
global_iops => $details->{iops},
read_iops => $details->{'rd-iops'},
write_iops => $details->{'wr-iops'},
};
2015-09-14 11:27:37 +02:00
}
2015-09-18 15:23:27 +02:00
if (scalar(keys %{$self->{ssd}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No entry found.");
$self->{output}->option_exit();
}
2015-09-14 11:27:37 +02:00
}
1;
__END__
=head1 MODE
2019-04-06 20:51:37 +02:00
Check SSDs usage.
2015-09-14 11:27:37 +02:00
=over 8
2019-04-06 20:51:37 +02:00
=item B<--warning-*> B<--critical-*>
2015-09-14 11:27:37 +02:00
Threshold warning (number of iops)
2019-04-06 20:51:37 +02:00
Can be: 'total', 'total-read', 'total-write',
'global', 'read', 'write'.
2015-09-14 11:27:37 +02:00
2015-09-18 15:23:27 +02:00
=item B<--filter-name>
2015-09-14 11:27:37 +02:00
Filter SSD name (can be a regexp). (e.g --filter-name '.*' for all SSDs)
2015-09-14 11:27:37 +02:00
=back
=cut