| 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 storage::emc::datadomain::snmp::mode::components::fan; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use centreon::plugins::misc; |
| 26 |
|
| 27 |
my %map_fan_status = ( |
| 28 |
0 => 'notfound', |
| 29 |
1 => 'ok', |
| 30 |
2 => 'failed' |
| 31 |
); |
| 32 |
my %level_map = ( |
| 33 |
0 => 'unknown', |
| 34 |
1 => 'low', |
| 35 |
2 => 'normal', |
| 36 |
3 => 'high' |
| 37 |
); |
| 38 |
|
| 39 |
my ($oid_fanDescription, $oid_fanLevel, $oid_fanStatus); |
| 40 |
my $oid_fanPropertiesEntry = '.1.3.6.1.4.1.19746.1.1.3.1.1.1'; |
| 41 |
|
| 42 |
sub load { |
| 43 |
my ($self) = @_; |
| 44 |
|
| 45 |
push @{$self->{request}}, { oid => $oid_fanPropertiesEntry }; |
| 46 |
} |
| 47 |
|
| 48 |
sub check { |
| 49 |
my ($self) = @_; |
| 50 |
|
| 51 |
$self->{output}->output_add(long_msg => "Checking fans"); |
| 52 |
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; |
| 53 |
return if ($self->check_filter(section => 'fan')); |
| 54 |
|
| 55 |
if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) { |
| 56 |
$oid_fanDescription = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.4'; |
| 57 |
$oid_fanLevel = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.5'; |
| 58 |
$oid_fanStatus = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.6'; |
| 59 |
} else { |
| 60 |
$oid_fanDescription = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.3'; |
| 61 |
$oid_fanLevel = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.4'; |
| 62 |
$oid_fanStatus = '.1.3.6.1.4.1.19746.1.1.3.1.1.1.5'; |
| 63 |
} |
| 64 |
|
| 65 |
foreach my $oid (keys %{$self->{results}->{$oid_fanPropertiesEntry}}) { |
| 66 |
next if ($oid !~ /^$oid_fanStatus\.(.*)$/); |
| 67 |
my $instance = $1; |
| 68 |
my $fan_descr = centreon::plugins::misc::trim($self->{results}->{$oid_fanPropertiesEntry}->{$oid_fanDescription . '.' . $instance}); |
| 69 |
my $fan_status = defined($map_fan_status{$self->{results}->{$oid_fanPropertiesEntry}->{$oid}}) ? |
| 70 |
$map_fan_status{$self->{results}->{$oid_fanPropertiesEntry}->{$oid}} : 'unknown'; |
| 71 |
my $fan_level = $self->{results}->{$oid_fanPropertiesEntry}->{$oid_fanLevel . '.' . $instance}; |
| 72 |
|
| 73 |
next if ($self->check_filter(section => 'fan', instance => $instance)); |
| 74 |
next if ($fan_status =~ /notfound/i && |
| 75 |
$self->absent_problem(section => 'fan', instance => $instance)); |
| 76 |
|
| 77 |
$self->{components}->{fan}->{total}++; |
| 78 |
$self->{output}->output_add( |
| 79 |
long_msg => sprintf( |
| 80 |
"fan '%s' status is '%s' [instance: %s, level: %s]", |
| 81 |
$fan_descr, $fan_status, $instance, $level_map{$fan_level} |
| 82 |
) |
| 83 |
); |
| 84 |
|
| 85 |
my $exit = $self->get_severity(section => 'fan', value => $fan_status); |
| 86 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 87 |
$self->{output}->output_add( |
| 88 |
severity => $exit, |
| 89 |
short_msg => sprintf("Fan '%s' status is '%s'", $fan_descr, $fan_status) |
| 90 |
); |
| 91 |
} |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
1; |