From 954742ed7ae8aa61facf71744eefa5a183c2c345 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Wed, 19 Apr 2023 13:41:15 +0200 Subject: [PATCH] (plugin) storage::emc::unisphere::restapi - mode hardware add component memmodule (#4367) --- .../restapi/mode/components/battery.pm | 6 +- .../unisphere/restapi/mode/components/disk.pm | 4 +- .../unisphere/restapi/mode/components/dpe.pm | 4 +- .../unisphere/restapi/mode/components/fan.pm | 4 +- .../restapi/mode/components/iomodule.pm | 4 +- .../restapi/mode/components/memmodule.pm | 65 +++++++++++++++++++ .../unisphere/restapi/mode/components/psu.pm | 4 +- .../unisphere/restapi/mode/components/sp.pm | 2 +- .../unisphere/restapi/mode/components/ssd.pm | 2 +- .../emc/unisphere/restapi/mode/hardware.pm | 10 +-- 10 files changed, 85 insertions(+), 20 deletions(-) create mode 100644 src/storage/emc/unisphere/restapi/mode/components/memmodule.pm diff --git a/src/storage/emc/unisphere/restapi/mode/components/battery.pm b/src/storage/emc/unisphere/restapi/mode/components/battery.pm index 1549d0258..ec89ae5e0 100644 --- a/src/storage/emc/unisphere/restapi/mode/components/battery.pm +++ b/src/storage/emc/unisphere/restapi/mode/components/battery.pm @@ -47,11 +47,11 @@ sub check { my $health = $health_status->{ $result->{content}->{health}->{value} }; $self->{output}->output_add( long_msg => sprintf( - "battery '%s' status is '%s' [instance = %s]", - $result->{content}->{name}, $health, $instance, + "battery '%s' status is '%s' [instance: %s]", + $result->{content}->{name}, $health, $instance ) ); - + my $exit = $self->get_severity(label => 'health', section => 'battery', value => $health); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( diff --git a/src/storage/emc/unisphere/restapi/mode/components/disk.pm b/src/storage/emc/unisphere/restapi/mode/components/disk.pm index 848469d40..7ebce24c7 100644 --- a/src/storage/emc/unisphere/restapi/mode/components/disk.pm +++ b/src/storage/emc/unisphere/restapi/mode/components/disk.pm @@ -47,8 +47,8 @@ sub check { my $health = $health_status->{ $result->{content}->{health}->{value} }; $self->{output}->output_add( long_msg => sprintf( - "disk '%s' status is '%s' [instance = %s]", - $result->{content}->{name}, $health, $instance, + "disk '%s' status is '%s' [instance: %s]", + $result->{content}->{name}, $health, $instance ) ); diff --git a/src/storage/emc/unisphere/restapi/mode/components/dpe.pm b/src/storage/emc/unisphere/restapi/mode/components/dpe.pm index be7a4a672..5950bf8c5 100644 --- a/src/storage/emc/unisphere/restapi/mode/components/dpe.pm +++ b/src/storage/emc/unisphere/restapi/mode/components/dpe.pm @@ -47,8 +47,8 @@ sub check { my $health = $health_status->{ $result->{content}->{health}->{value} }; $self->{output}->output_add( long_msg => sprintf( - "dpe '%s' status is '%s' [instance = %s]", - $result->{content}->{name}, $health, $instance, + "dpe '%s' status is '%s' [instance: %s]", + $result->{content}->{name}, $health, $instance ) ); diff --git a/src/storage/emc/unisphere/restapi/mode/components/fan.pm b/src/storage/emc/unisphere/restapi/mode/components/fan.pm index 5a450c0d4..950133da5 100644 --- a/src/storage/emc/unisphere/restapi/mode/components/fan.pm +++ b/src/storage/emc/unisphere/restapi/mode/components/fan.pm @@ -47,8 +47,8 @@ sub check { my $health = $health_status->{ $result->{content}->{health}->{value} }; $self->{output}->output_add( long_msg => sprintf( - "fan '%s' status is '%s' [instance = %s]", - $result->{content}->{id}, $health, $instance, + "fan '%s' status is '%s' [instance: %s]", + $result->{content}->{id}, $health, $instance ) ); diff --git a/src/storage/emc/unisphere/restapi/mode/components/iomodule.pm b/src/storage/emc/unisphere/restapi/mode/components/iomodule.pm index 5213d5e4c..3f6a5c617 100644 --- a/src/storage/emc/unisphere/restapi/mode/components/iomodule.pm +++ b/src/storage/emc/unisphere/restapi/mode/components/iomodule.pm @@ -47,8 +47,8 @@ sub check { my $health = $health_status->{ $result->{content}->{health}->{value} }; $self->{output}->output_add( long_msg => sprintf( - "iomodule '%s' status is '%s' [instance = %s]", - $result->{content}->{name}, $health, $instance, + "iomodule '%s' status is '%s' [instance: %s]", + $result->{content}->{name}, $health, $instance ) ); diff --git a/src/storage/emc/unisphere/restapi/mode/components/memmodule.pm b/src/storage/emc/unisphere/restapi/mode/components/memmodule.pm new file mode 100644 index 000000000..382b12361 --- /dev/null +++ b/src/storage/emc/unisphere/restapi/mode/components/memmodule.pm @@ -0,0 +1,65 @@ +# +# Copyright 2023 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::emc::unisphere::restapi::mode::components::memmodule; + +use strict; +use warnings; +use storage::emc::unisphere::restapi::mode::components::resources qw($health_status); + +sub load { + my ($self) = @_; + + $self->{json_results}->{memmodules} = $self->{custom}->request_api(method => 'GET', url_path => '/api/types/memoryModule/instances?fields=name,health'); +} + +sub check { + my ($self) = @_; + + $self->{output}->output_add(long_msg => 'checking memmodules'); + $self->{components}->{memmodule} = { name => 'memmodules', total => 0, skip => 0 }; + return if ($self->check_filter(section => 'memmodule')); + return if (!defined($self->{json_results}->{memmodules})); + + foreach my $result (@{$self->{json_results}->{memmodules}->{entries}}) { + my $instance = $result->{content}->{id}; + + next if ($self->check_filter(section => 'memmodule', instance => $instance)); + $self->{components}->{memmodule}->{total}++; + + my $health = $health_status->{ $result->{content}->{health}->{value} }; + $self->{output}->output_add( + long_msg => sprintf( + "memory module '%s' status is '%s' [instance: %s]", + $result->{content}->{name}, $health, $instance + ) + ); + + my $exit = $self->get_severity(label => 'health', section => 'memmodule', value => $health); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("memory module '%s' status is '%s'", $result->{content}->{name}, $health) + ); + } + } +} + +1; diff --git a/src/storage/emc/unisphere/restapi/mode/components/psu.pm b/src/storage/emc/unisphere/restapi/mode/components/psu.pm index 2655a7f1f..c5f557f02 100644 --- a/src/storage/emc/unisphere/restapi/mode/components/psu.pm +++ b/src/storage/emc/unisphere/restapi/mode/components/psu.pm @@ -47,8 +47,8 @@ sub check { my $health = $health_status->{ $result->{content}->{health}->{value} }; $self->{output}->output_add( long_msg => sprintf( - "power supply '%s' status is '%s' [instance = %s]", - $result->{content}->{name}, $health, $instance, + "power supply '%s' status is '%s' [instance: %s]", + $result->{content}->{name}, $health, $instance ) ); diff --git a/src/storage/emc/unisphere/restapi/mode/components/sp.pm b/src/storage/emc/unisphere/restapi/mode/components/sp.pm index 611b35d59..a6614cf7a 100644 --- a/src/storage/emc/unisphere/restapi/mode/components/sp.pm +++ b/src/storage/emc/unisphere/restapi/mode/components/sp.pm @@ -48,7 +48,7 @@ sub check { my $health = $health_status->{ $result->{content}->{health}->{value} }; $self->{output}->output_add( long_msg => sprintf( - "storage processor '%s' status is '%s' [instance = %s]", + "storage processor '%s' status is '%s' [instance: %s]", $name, $health, $instance ) ); diff --git a/src/storage/emc/unisphere/restapi/mode/components/ssd.pm b/src/storage/emc/unisphere/restapi/mode/components/ssd.pm index 55fe80490..b7380aa7b 100644 --- a/src/storage/emc/unisphere/restapi/mode/components/ssd.pm +++ b/src/storage/emc/unisphere/restapi/mode/components/ssd.pm @@ -48,7 +48,7 @@ sub check { my $health = $health_status->{ $result->{content}->{health}->{value} }; $self->{output}->output_add( long_msg => sprintf( - "ssd '%s' status is '%s' [instance = %s]", + "ssd '%s' status is '%s' [instance: %s]", $name, $health, $instance ) ); diff --git a/src/storage/emc/unisphere/restapi/mode/hardware.pm b/src/storage/emc/unisphere/restapi/mode/hardware.pm index 7802770e0..263b1d5ce 100644 --- a/src/storage/emc/unisphere/restapi/mode/hardware.pm +++ b/src/storage/emc/unisphere/restapi/mode/hardware.pm @@ -41,12 +41,12 @@ sub set_system { ['major', 'CRITICAL'], ['critical', 'CRITICAL'], ['non_recoverable', 'CRITICAL'], - ['unknown', 'UNKNOWN'], - ], + ['unknown', 'UNKNOWN'] + ] }; - + $self->{components_path} = 'storage::emc::unisphere::restapi::mode::components'; - $self->{components_module} = ['disk', 'fan', 'iomodule', 'psu', 'dpe', 'battery', 'ssd', 'sp']; + $self->{components_module} = ['disk', 'fan', 'iomodule', 'memmodule', 'psu', 'dpe', 'battery', 'ssd', 'sp']; } sub new { @@ -76,7 +76,7 @@ Check hardware. =item B<--component> Which component to check (Default: '.*'). -Can be: 'disk', 'fan', 'iomodule', 'psu', 'dpe', 'battery', 'ssd', 'sp'. +Can be: 'disk', 'fan', 'iomodule', 'memmodule', 'psu', 'dpe', 'battery', 'ssd', 'sp'. =item B<--filter>