| 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::hp::proliant::snmp::mode::components::fan; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my %map_fan_condition = ( |
| 27 |
1 => 'other', |
| 28 |
2 => 'ok', |
| 29 |
3 => 'degraded', |
| 30 |
4 => 'failed', |
| 31 |
); |
| 32 |
my %map_present = ( |
| 33 |
1 => 'other', |
| 34 |
2 => 'absent', |
| 35 |
3 => 'present', |
| 36 |
); |
| 37 |
my %map_redundant = ( |
| 38 |
1 => 'other', |
| 39 |
2 => 'not redundant', |
| 40 |
3 => 'redundant', |
| 41 |
); |
| 42 |
my %map_location = ( |
| 43 |
1 => "other", |
| 44 |
2 => "unknown", |
| 45 |
3 => "system", |
| 46 |
4 => "systemBoard", |
| 47 |
5 => "ioBoard", |
| 48 |
6 => "cpu", |
| 49 |
7 => "memory", |
| 50 |
8 => "storage", |
| 51 |
9 => "removableMedia", |
| 52 |
10 => "powerSupply", |
| 53 |
11 => "ambient", |
| 54 |
12 => "chassis", |
| 55 |
13 => "bridgeCard", |
| 56 |
14 => "managementBoard", |
| 57 |
15 => "backplane", |
| 58 |
16 => "networkSlot", |
| 59 |
17 => "bladeSlot", |
| 60 |
18 => "virtual", |
| 61 |
); |
| 62 |
my %map_fanspeed = ( |
| 63 |
1 => "other", |
| 64 |
2 => "normal", |
| 65 |
3 => "high", |
| 66 |
); |
| 67 |
|
| 68 |
# In MIB 'CPQHLTH-MIB.mib' |
| 69 |
my $mapping = { |
| 70 |
cpqHeFltTolFanLocale => { oid => '.1.3.6.1.4.1.232.6.2.6.7.1.3', map => \%map_location }, |
| 71 |
cpqHeFltTolFanPresent => { oid => '.1.3.6.1.4.1.232.6.2.6.7.1.4', map => \%map_present }, |
| 72 |
cpqHeFltTolFanSpeed => { oid => '.1.3.6.1.4.1.232.6.2.6.7.1.6', map => \%map_fanspeed }, |
| 73 |
cpqHeFltTolFanRedundant => { oid => '.1.3.6.1.4.1.232.6.2.6.7.1.7', map => \%map_redundant }, |
| 74 |
cpqHeFltTolFanRedundantPartner => { oid => '.1.3.6.1.4.1.232.6.2.6.7.1.8' }, |
| 75 |
cpqHeFltTolFanCondition => { oid => '.1.3.6.1.4.1.232.6.2.6.7.1.9', map => \%map_fan_condition }, |
| 76 |
cpqHeFltTolFanCurrentSpeed => { oid => '.1.3.6.1.4.1.232.6.2.6.7.1.12' }, |
| 77 |
}; |
| 78 |
my $oid_cpqHeFltTolFanEntry = '.1.3.6.1.4.1.232.6.2.6.7.1'; |
| 79 |
|
| 80 |
sub load { |
| 81 |
my ($self) = @_; |
| 82 |
|
| 83 |
push @{$self->{request}}, { oid => $oid_cpqHeFltTolFanEntry, start => $mapping->{cpqHeFltTolFanLocale}->{oid}, end => $mapping->{cpqHeFltTolFanCurrentSpeed}->{oid} }; |
| 84 |
} |
| 85 |
|
| 86 |
sub check { |
| 87 |
my ($self) = @_; |
| 88 |
|
| 89 |
|
| 90 |
$self->{output}->output_add(long_msg => "Checking fans"); |
| 91 |
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; |
| 92 |
return if ($self->check_filter(section => 'fan')); |
| 93 |
|
| 94 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpqHeFltTolFanEntry}})) { |
| 95 |
next if ($oid !~ /^$mapping->{cpqHeFltTolFanCondition}->{oid}\.(.*)$/); |
| 96 |
my $instance = $1; |
| 97 |
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpqHeFltTolFanEntry}, instance => $instance); |
| 98 |
|
| 99 |
next if ($self->check_filter(section => 'fan', instance => $instance)); |
| 100 |
next if ($result->{cpqHeFltTolFanPresent} !~ /present/i && |
| 101 |
$self->absent_problem(section => 'fan', instance => $instance)); |
| 102 |
$self->{components}->{fan}->{total}++; |
| 103 |
|
| 104 |
$self->{output}->output_add(long_msg => sprintf("fan '%s' status is %s, speed is %s [location: %s, redundance: %s, redundant partner: %s].", |
| 105 |
$instance, $result->{cpqHeFltTolFanCondition}, $result->{cpqHeFltTolFanSpeed}, |
| 106 |
$result->{cpqHeFltTolFanLocale}, |
| 107 |
$result->{cpqHeFltTolFanRedundant}, $result->{cpqHeFltTolFanRedundantPartner} |
| 108 |
)); |
| 109 |
my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{cpqHeFltTolFanCondition}); |
| 110 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 111 |
$self->{output}->output_add(severity => $exit, |
| 112 |
short_msg => sprintf("fan '%s' status is %s", |
| 113 |
$instance, $result->{cpqHeFltTolFanCondition})); |
| 114 |
} |
| 115 |
|
| 116 |
if (defined($result->{cpqHeFltTolFanCurrentSpeed})) { |
| 117 |
$self->{output}->perfdata_add( |
| 118 |
unit => 'rpm', |
| 119 |
nlabel => 'hardware.fan.speed.rpm', |
| 120 |
instances => $instance, |
| 121 |
value => $result->{cpqHeFltTolFanCurrentSpeed} |
| 122 |
); |
| 123 |
} |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
1; |