| 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::dell::omem::snmp::mode::components::health; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_health_status = ( |
| 27 |
1 => 'other', |
| 28 |
2 => 'unknown', |
| 29 |
3 => 'ok', |
| 30 |
4 => 'nonCritical', |
| 31 |
5 => 'critical', |
| 32 |
6 => 'nonRecoverable' |
| 33 |
); |
| 34 |
|
| 35 |
my $mapping = { |
| 36 |
IOMCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.1', map => \%map_health_status, descr => 'IOM' }, |
| 37 |
redCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.2', map => \%map_health_status, descr => 'redundancy' }, |
| 38 |
powerCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.3', map => \%map_health_status, descr => 'power' }, |
| 39 |
fanCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.4', map => \%map_health_status, descr => 'fan' }, |
| 40 |
bladeCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.5', map => \%map_health_status, descr => 'blade' }, |
| 41 |
tempCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.6', map => \%map_health_status, descr => 'temperature' }, |
| 42 |
MMCurrStatus => { oid => '.1.3.6.1.4.1.674.10892.6.3.1.7', map => \%map_health_status, descr => 'management module' } |
| 43 |
}; |
| 44 |
my $oid_dmmStatusNowGroup = '.1.3.6.1.4.1.674.10892.6.3.1'; |
| 45 |
|
| 46 |
sub load {} |
| 47 |
|
| 48 |
sub check { |
| 49 |
my ($self) = @_; |
| 50 |
|
| 51 |
$self->{output}->output_add(long_msg => "Checking health"); |
| 52 |
$self->{components}->{health} = { name => 'health', total => 0, skip => 0 }; |
| 53 |
return if ($self->check_filter(section => 'health')); |
| 54 |
|
| 55 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_dmmStatusNowGroup}, instance => 0); |
| 56 |
foreach my $probe (sort keys %$mapping) { |
| 57 |
next if (!defined($result->{$probe})); |
| 58 |
|
| 59 |
$mapping->{$probe}->{oid} =~ /\.(\d+)$/; |
| 60 |
my $instance = $1; |
| 61 |
|
| 62 |
next if ( $self->check_filter(section => 'health', instance => $instance)); |
| 63 |
$self->{components}->{health}->{total}++; |
| 64 |
|
| 65 |
$self->{output}->output_add( |
| 66 |
long_msg => sprintf( |
| 67 |
"%s status is %s [instance: %s]", |
| 68 |
$mapping->{$probe}->{descr}, |
| 69 |
$result->{$probe}, |
| 70 |
$instance |
| 71 |
) |
| 72 |
); |
| 73 |
|
| 74 |
my $exit = $self->get_severity(label => 'default', section => 'health', value => $result->{$probe}); |
| 75 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 76 |
$self->{output}->output_add( |
| 77 |
severity => $exit, |
| 78 |
short_msg => sprintf("%s status is %s", |
| 79 |
$mapping->{$probe}->{descr}, |
| 80 |
$result->{$probe} |
| 81 |
) |
| 82 |
); |
| 83 |
} |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
1; |