| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package hardware::server::ibm::mgmt_cards::imm::snmp::mode::components::global; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::mode); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
my %map_global_status = ( |
| 29 |
0 => 'non recoverable', |
| 30 |
2 => 'critical', |
| 31 |
4 => 'non critical', |
| 32 |
255 => 'nominal', |
| 33 |
); |
| 34 |
|
| 35 |
my $mapping = { |
| 36 |
systemHealthStat => { oid => '.1.3.6.1.4.1.2.3.51.3.1.4.1', map => \%map_global_status }, |
| 37 |
}; |
| 38 |
|
| 39 |
sub load { |
| 40 |
my ($self) = @_; |
| 41 |
|
| 42 |
push @{$self->{request}}, { oid => $mapping->{systemHealthStat}->{oid} }; |
| 43 |
} |
| 44 |
|
| 45 |
sub check { |
| 46 |
my ($self) = @_; |
| 47 |
|
| 48 |
$self->{output}->output_add(long_msg => "Checking system health"); |
| 49 |
$self->{components}->{global} = {name => 'system health', total => 0, skip => 0}; |
| 50 |
return if ($self->check_filter(section => 'global')); |
| 51 |
|
| 52 |
return if (!defined($self->{results}->{$mapping->{systemHealthStat}->{oid}}) || scalar(keys %{$self->{results}->{$mapping->{systemHealthStat}->{oid}}}) <= 0); |
| 53 |
|
| 54 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{systemHealthStat}->{oid}}, instance => '0'); |
| 55 |
$self->{components}->{global}->{total}++; |
| 56 |
|
| 57 |
$self->{output}->output_add( |
| 58 |
long_msg => sprintf( |
| 59 |
"system health status is '%s'", |
| 60 |
$result->{systemHealthStat} |
| 61 |
) |
| 62 |
); |
| 63 |
my $exit = $self->get_severity(section => 'global', value => $result->{systemHealthStat}); |
| 64 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 65 |
$self->{output}->output_add( |
| 66 |
severity => $exit, |
| 67 |
short_msg => sprintf( |
| 68 |
"System health status is '%s'.", |
| 69 |
$result->{systemHealthStat} |
| 70 |
) |
| 71 |
); |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
1; |