Debian Codegraph @

src/hardware/server/dell/openmanage/snmp/mode/components/fan.pm

raw
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::openmanage::snmp::mode::components::fan;
22
23 use strict;
24 use warnings;
25
26 my %map_status = (
27 1 => 'other',
28 2 => 'unknown',
29 3 => 'ok',
30 4 => 'nonCriticalUpper',
31 5 => 'criticalUpper',
32 6 => 'nonRecoverableUpper',
33 7 => 'nonCriticalLower',
34 8 => 'criticalLower',
35 9 => 'nonRecoverableLower',
36 10 => 'failed',
37 );
38
39 # In MIB '10892.mib'
40 my $mapping = {
41 coolingDeviceStatus => { oid => '.1.3.6.1.4.1.674.10892.1.700.12.1.5', map => \%map_status },
42 coolingDeviceReading => { oid => '.1.3.6.1.4.1.674.10892.1.700.12.1.6' },
43 };
44 my $mapping2 = {
45 coolingDeviceLocationName => { oid => '.1.3.6.1.4.1.674.10892.1.700.12.1.8' },
46 };
47 my $oid_coolingDeviceTableEntry = '.1.3.6.1.4.1.674.10892.1.700.12.1';
48
49 sub load {
50 my ($self) = @_;
51
52 push @{$self->{request}}, { oid => $oid_coolingDeviceTableEntry, start => $mapping->{coolingDeviceStatus}->{oid}, end => $mapping->{coolingDeviceReading}->{oid} },
53 { oid => $mapping2->{coolingDeviceLocationName}->{oid} };
54 }
55
56 sub check {
57 my ($self) = @_;
58
59 $self->{output}->output_add(long_msg => "Checking fans");
60 $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
61 return if ($self->check_filter(section => 'fan'));
62
63 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_coolingDeviceTableEntry}})) {
64 next if ($oid !~ /^$mapping->{coolingDeviceStatus}->{oid}\.(.*)$/);
65 my $instance = $1;
66 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_coolingDeviceTableEntry}, instance => $instance);
67 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{coolingDeviceLocationName}->{oid}}, instance => $instance);
68
69 next if ($self->check_filter(section => 'fan', instance => $instance));
70
71 $self->{components}->{fan}->{total}++;
72
73 $self->{output}->output_add(long_msg => sprintf("Fan '%s' status is '%s' [instance: %s, Location: %s, reading: %s]",
74 $instance, $result->{coolingDeviceStatus}, $instance,
75 $result2->{coolingDeviceLocationName}, $result->{coolingDeviceReading}
76 ));
77 my $exit = $self->get_severity(label => 'default', section => 'fan', value => $result->{coolingDeviceStatus});
78 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
79 $self->{output}->output_add(severity => $exit,
80 short_msg => sprintf("Fan '%s' status is '%s'",
81 $instance, $result->{coolingDeviceStatus}));
82 }
83
84 if (defined($result->{coolingDeviceReading}) && $result->{coolingDeviceReading} =~ /[0-9]/) {
85 my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $result->{coolingDeviceReading});
86
87 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
88 $self->{output}->output_add(severity => $exit,
89 short_msg => sprintf("Fan '%s' speed is %s rpm", $instance, $result->{coolingDeviceReading}));
90 }
91 $self->{output}->perfdata_add(
92 label => 'fan', unit => 'rpm',
93 nlabel => 'hardware.fan.speed.rpm',
94 instances => $instance,
95 value => $result->{coolingDeviceReading},
96 warning => $warn,
97 critical => $crit,
98 min => 0
99 );
100 }
101 }
102 }
103
104 1;