| 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::cisco::ucs::snmp::mode::components::fan; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
use hardware::server::cisco::ucs::snmp::mode::components::resources qw(%mapping_presence %mapping_operability); |
| 26 |
|
| 27 |
# In MIB 'CISCO-UNIFIED-COMPUTING-EQUIPMENT-MIB' |
| 28 |
my $mapping1 = { |
| 29 |
cucsEquipmentFanPresence => { oid => '.1.3.6.1.4.1.9.9.719.1.15.12.1.13', map => \%mapping_presence }, |
| 30 |
}; |
| 31 |
my $mapping2 = { |
| 32 |
cucsEquipmentFanOperState => { oid => '.1.3.6.1.4.1.9.9.719.1.15.12.1.9', map => \%mapping_operability }, |
| 33 |
}; |
| 34 |
my $oid_cucsEquipmentFanDn = '.1.3.6.1.4.1.9.9.719.1.15.12.1.2'; |
| 35 |
|
| 36 |
sub load { |
| 37 |
my ($self) = @_; |
| 38 |
|
| 39 |
push @{$self->{request}}, { oid => $mapping1->{cucsEquipmentFanPresence}->{oid} }, |
| 40 |
{ oid => $mapping2->{cucsEquipmentFanOperState}->{oid} }, { oid => $oid_cucsEquipmentFanDn }; |
| 41 |
} |
| 42 |
|
| 43 |
sub check { |
| 44 |
my ($self) = @_; |
| 45 |
|
| 46 |
$self->{output}->output_add(long_msg => "Checking fans"); |
| 47 |
$self->{components}->{fan} = {name => 'fans', total => 0, skip => 0}; |
| 48 |
return if ($self->check_filter(section => 'fan')); |
| 49 |
|
| 50 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cucsEquipmentFanDn}})) { |
| 51 |
$oid =~ /\.(\d+)$/; |
| 52 |
my $instance = $1; |
| 53 |
my $fan_dn = $self->{results}->{$oid_cucsEquipmentFanDn}->{$oid}; |
| 54 |
my $result = $self->{snmp}->map_instance(mapping => $mapping1, results => $self->{results}->{$mapping1->{cucsEquipmentFanPresence}->{oid}}, instance => $instance); |
| 55 |
my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{cucsEquipmentFanOperState}->{oid}}, instance => $instance); |
| 56 |
|
| 57 |
next if ($self->absent_problem(section => 'fan', instance => $fan_dn)); |
| 58 |
next if ($self->check_filter(section => 'fan', instance => $fan_dn)); |
| 59 |
|
| 60 |
$self->{output}->output_add( |
| 61 |
long_msg => sprintf( |
| 62 |
"fan '%s' state is '%s' [presence: %s].", |
| 63 |
$fan_dn, $result2->{cucsEquipmentFanOperState}, |
| 64 |
$result->{cucsEquipmentFanPresence} |
| 65 |
) |
| 66 |
); |
| 67 |
|
| 68 |
my $exit = $self->get_severity(section => 'fan.presence', label => 'default.presence', value => $result->{cucsEquipmentFanPresence}); |
| 69 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 70 |
$self->{output}->output_add( |
| 71 |
severity => $exit, |
| 72 |
short_msg => sprintf( |
| 73 |
"fan '%s' presence is: '%s'", |
| 74 |
$fan_dn, $result->{cucsEquipmentFanPresence} |
| 75 |
) |
| 76 |
); |
| 77 |
next; |
| 78 |
} |
| 79 |
|
| 80 |
$self->{components}->{fan}->{total}++; |
| 81 |
|
| 82 |
$exit = $self->get_severity(section => 'fan.operability', label => 'default.operability', value => $result2->{cucsEquipmentFanOperState}); |
| 83 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 84 |
$self->{output}->output_add( |
| 85 |
severity => $exit, |
| 86 |
short_msg => sprintf( |
| 87 |
"fan '%s' state is '%s'", |
| 88 |
$fan_dn, $result2->{cucsEquipmentFanOperState} |
| 89 |
) |
| 90 |
); |
| 91 |
} |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
1; |