(plugin) storage::dell::powerstore::restapi - add clusters mode (#3806)
This commit is contained in:
parent
9a3e21d7bd
commit
53c3393687
|
@ -133,13 +133,43 @@ sub get_port {
|
||||||
return $self->{port};
|
return $self->{port};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub get_metrics_by_clusters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $clusters = $self->request_api(endpoint => '/api/rest/cluster');
|
||||||
|
|
||||||
|
my $results = {};
|
||||||
|
foreach (@$clusters) {
|
||||||
|
my $post_json = JSON::XS->new->utf8->encode(
|
||||||
|
{
|
||||||
|
entity => 'performance_metrics_by_cluster',
|
||||||
|
entity_id => $_->{id},
|
||||||
|
interval => 'Five_Mins'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
my $perfs = $self->request_api(
|
||||||
|
method => 'POST',
|
||||||
|
endpoint => '/api/rest/metrics/generate',
|
||||||
|
headers => ['Content-Type: application/json'],
|
||||||
|
query_form_post => $post_json
|
||||||
|
);
|
||||||
|
$results->{ $_->{id} } = $perfs;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
sub request_api {
|
sub request_api {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->settings();
|
$self->settings();
|
||||||
my $content = $self->{http}->request(
|
my $content = $self->{http}->request(
|
||||||
|
method => defined($options{method}) ? $options{method} : 'GET',
|
||||||
url_path => $options{endpoint},
|
url_path => $options{endpoint},
|
||||||
get_param => $options{get_param},
|
get_param => $options{get_param},
|
||||||
|
header => $options{headers},
|
||||||
|
query_form_post => $options{query_form_post},
|
||||||
unknown_status => $self->{unknown_http_status},
|
unknown_status => $self->{unknown_http_status},
|
||||||
warning_status => $self->{warning_http_status},
|
warning_status => $self->{warning_http_status},
|
||||||
critical_status => $self->{critical_http_status}
|
critical_status => $self->{critical_http_status}
|
||||||
|
|
|
@ -0,0 +1,263 @@
|
||||||
|
#
|
||||||
|
# Copyright 2022 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# 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::dell::powerstore::restapi::mode::clusters;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub cluster_long_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"checking cluster '%s'",
|
||||||
|
$options{instance}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_cluster_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
"cluster '%s' ",
|
||||||
|
$options{instance}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_global_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'Number of clusters ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_read_latency_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'read latency ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_write_latency_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'write latency ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_read_iops_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'read iops ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_write_iops_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'write iops ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_read_bandwidth_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'read bandwidth ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_write_bandwidth_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return 'write bandwidth ';
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
|
||||||
|
{
|
||||||
|
name => 'clusters', type => 3, cb_prefix_output => 'prefix_cluster_output', cb_long_output => 'cluster_long_output', indent_long_output => ' ', message_multiple => 'All clusters are ok',
|
||||||
|
group => [
|
||||||
|
{ name => 'read_latency', type => 0, cb_prefix_output => 'prefix_read_latency_output' },
|
||||||
|
{ name => 'write_latency', type => 0, cb_prefix_output => 'prefix_write_latency_output' },
|
||||||
|
{ name => 'read_iops', type => 0, cb_prefix_output => 'prefix_read_iops_output' },
|
||||||
|
{ name => 'write_iops', type => 0, cb_prefix_output => 'prefix_write_iops_output' },
|
||||||
|
{ name => 'read_bandwidth', type => 0, cb_prefix_output => 'prefix_read_bandwidth_output' },
|
||||||
|
{ name => 'write_bandwidth', type => 0, cb_prefix_output => 'prefix_write_bandwidth_output' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'clusters-detected', display_ok => 0, nlabel => 'clusters.detected.count', set => {
|
||||||
|
key_values => [ { name => 'detected' } ],
|
||||||
|
output_template => 'detected: %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%s', min => 0 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ('read', 'write') {
|
||||||
|
$self->{maps_counters}->{$_ . '_latency'} = [];
|
||||||
|
foreach my $sampling ('5m', '30m', '1h', '24h') {
|
||||||
|
push @{$self->{maps_counters}->{$_ . '_latency'}}, {
|
||||||
|
label => $_ . '-latency-' . $sampling, nlabel => 'cluster.io.'. $_ . '.latency.' . $sampling . '.microseconds', set => {
|
||||||
|
key_values => [ { name => $sampling } ],
|
||||||
|
output_template => '%.2f µs (' . $sampling . ')',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', min => 0, label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $sampling ('5m', '30m', '1h', '24h') {
|
||||||
|
push @{$self->{maps_counters}->{$_ . '_iops'}}, {
|
||||||
|
label => $_ . '-iops-' . $sampling, nlabel => 'cluster.io.'. $_ . '.' . $sampling . '.iops', set => {
|
||||||
|
key_values => [ { name => $sampling } ],
|
||||||
|
output_template => '%d (' . $sampling . ')',
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%d', unit => 'iops', min => 0, label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $sampling ('5m', '30m', '1h', '24h') {
|
||||||
|
push @{$self->{maps_counters}->{$_ . '_bandwidth'}}, {
|
||||||
|
label => $_ . '-bandwidth-' . $sampling, nlabel => 'cluster.io.'. $_ . '.bandwidth.' . $sampling . '.bytespersecond', set => {
|
||||||
|
key_values => [ { name => $sampling } ],
|
||||||
|
output_template => '%.2f%s/s (' . $sampling . ')',
|
||||||
|
output_change_bytes => 1,
|
||||||
|
perfdatas => [
|
||||||
|
{ template => '%.2f', unit => 'B/s', min => 0, label_extra_instance => 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
'filter-id:s' => { name => 'filter_id' }
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $clusters = $options{custom}->get_metrics_by_clusters();
|
||||||
|
|
||||||
|
$self->{global} = { detected => 0 };
|
||||||
|
$self->{clusters} = {};
|
||||||
|
|
||||||
|
foreach my $cluster_id (keys %$clusters) {
|
||||||
|
next if (defined($self->{option_results}->{filter_id}) && $self->{option_results}->{filter_id} ne '' &&
|
||||||
|
$cluster_id !~ /$self->{option_results}->{filter_id}/);
|
||||||
|
|
||||||
|
$self->{global}->{detected}++;
|
||||||
|
|
||||||
|
$self->{clusters}->{ $cluster_id } = {
|
||||||
|
latency => {},
|
||||||
|
iops => {},
|
||||||
|
bandwidth => {}
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach my $sampling ('5m', '30m', '1h', '24h') {
|
||||||
|
foreach my $metric ('read_latency', 'write_latency', 'read_iops', 'write_iops', 'read_bandwidth', 'write_bandwidth') {
|
||||||
|
$self->{clusters}->{ $cluster_id }->{$metric}->{$sampling} = 0;
|
||||||
|
$self->{clusters}->{ $cluster_id }->{$metric}->{'num_' . $sampling} = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $i = 0;
|
||||||
|
while (my $entry = pop(@{$clusters->{$cluster_id}})) {
|
||||||
|
foreach ('latency', 'iops', 'bandwidth') {
|
||||||
|
if ($i == 0) {
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'read_' . $_}->{'5m'} += $entry->{'avg_read_' . $_};
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'write_' . $_}->{'5m'} += $entry->{'avg_write_' . $_};
|
||||||
|
}
|
||||||
|
if ($i < 5) {
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'read_' . $_}->{'30m'} += $entry->{'avg_read_' . $_};
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'write_' . $_}->{'30m'} += $entry->{'avg_write_' . $_};
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'read_' . $_}->{num_30m}++;
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'write_' . $_}->{num_30m}++;
|
||||||
|
}
|
||||||
|
if ($i < 10) {
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'read_' . $_}->{'1h'} += $entry->{'avg_read_' . $_};
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'write_' . $_}->{'1h'} += $entry->{'avg_write_' . $_};
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'read_' . $_}->{num_1h}++;
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'write_' . $_}->{num_1h}++;
|
||||||
|
}
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'read_' . $_}->{'24h'} += $entry->{'avg_read_' . $_};
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'write_' . $_}->{'24h'} += $entry->{'avg_write_' . $_};
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'read_' . $_}->{num_24h}++;
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'write_' . $_}->{num_24h}++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ('latency', 'iops', 'bandwidth') {
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'read_' . $_}->{'30m'} /= $self->{clusters}->{ $cluster_id }->{'read_' . $_}->{num_30m};
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'write_' . $_}->{'30m'} /= $self->{clusters}->{ $cluster_id }->{'write_' . $_}->{num_30m};
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'read_' . $_}->{'1h'} /= $self->{clusters}->{ $cluster_id }->{'read_' . $_}->{num_1h};
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'write_' . $_}->{'1h'} /= $self->{clusters}->{ $cluster_id }->{'write_' . $_}->{num_1h};
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'read_' . $_}->{'24h'} /= $self->{clusters}->{ $cluster_id }->{'read_' . $_}->{num_24h};
|
||||||
|
$self->{clusters}->{ $cluster_id }->{'write_' . $_}->{'24h'} /= $self->{clusters}->{ $cluster_id }->{'write_' . $_}->{num_24h};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check clusters.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--filter-id>
|
||||||
|
|
||||||
|
Filter clusters by id.
|
||||||
|
|
||||||
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
|
Thresholds.
|
||||||
|
Can be: 'clusters-detected',
|
||||||
|
'read-iops-5m', 'read-iops-30m', 'read-iops-1h', 'read-iops-24h',
|
||||||
|
'write-iops-5m', 'write-iops-30m', 'write-iops-1h', 'write-iops-24h',
|
||||||
|
'read-latency-5m', 'read-latency-30m', 'read-latency-1h', 'read-latency-24h',
|
||||||
|
'write-latency-5m', 'write-latency-30m', 'write-latency-1h', 'write-latency-24h',
|
||||||
|
'read-bandwidth-5m', 'read-bandwidth-30m', 'read-bandwidth-1h', 'read-bandwidth-24h',
|
||||||
|
'write-bandwidth-5m', 'write-bandwidth-30m', 'write-bandwidth-1h', 'write-bandwidth-24h'.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -29,9 +29,9 @@ sub new {
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '0.1';
|
|
||||||
$self->{modes} = {
|
$self->{modes} = {
|
||||||
'alerts' => 'storage::dell::powerstore::restapi::mode::alerts',
|
'alerts' => 'storage::dell::powerstore::restapi::mode::alerts',
|
||||||
|
'clusters' => 'storage::dell::powerstore::restapi::mode::clusters',
|
||||||
'hardware' => 'storage::dell::powerstore::restapi::mode::hardware'
|
'hardware' => 'storage::dell::powerstore::restapi::mode::hardware'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ sub store_long_output {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub store_appliance_output {
|
sub prefix_store_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
|
|
Loading…
Reference in New Issue