Debian Codegraph @

src/hardware/server/dell/openmanage/snmp/mode/components/temperature.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::temperature;
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 my %map_type = (
39 1 => 'other',
40 2 => 'unknown',
41 3 => 'Ambient ESM',
42 4 => 'Discrete',
43 );
44
45 # In MIB '10892.mib'
46 my $mapping = {
47 temperatureProbeStatus => { oid => '.1.3.6.1.4.1.674.10892.1.700.20.1.5', map => \%map_status },
48 temperatureProbeReading => { oid => '.1.3.6.1.4.1.674.10892.1.700.20.1.6' },
49 temperatureProbeType => { oid => '.1.3.6.1.4.1.674.10892.1.700.20.1.7', map => \%map_type },
50 temperatureProbeLocationName => { oid => '.1.3.6.1.4.1.674.10892.1.700.20.1.8' },
51 };
52 my $oid_temperatureProbeTable = '.1.3.6.1.4.1.674.10892.1.700.20';
53
54 sub load {
55 my ($self) = @_;
56
57 push @{$self->{request}}, { oid => $oid_temperatureProbeTable, start => $mapping->{temperatureProbeStatus}->{oid}, end => $mapping->{temperatureProbeLocationName}->{oid} };
58 }
59
60 sub check {
61 my ($self) = @_;
62
63 $self->{output}->output_add(long_msg => "Checking temperatures");
64 $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
65 return if ($self->check_filter(section => 'temperature'));
66
67 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_temperatureProbeTable}})) {
68 next if ($oid !~ /^$mapping->{temperatureProbeStatus}->{oid}\.(.*)$/);
69 my $instance = $1;
70 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_temperatureProbeTable}, instance => $instance);
71
72 next if ($self->check_filter(section => 'temperature', instance => $instance));
73
74 $self->{components}->{temperature}->{total}++;
75
76 $self->{output}->output_add(long_msg => sprintf("Temperature '%s' status is '%s' [instance: %s, location: %s, reading: %s]",
77 $instance, $result->{temperatureProbeStatus}, $instance,
78 $result->{temperatureProbeLocationName}, $result->{temperatureProbeReading}
79 ));
80 my $exit = $self->get_severity(label => 'default', section => 'temperature', value => $result->{temperatureProbeStatus});
81 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
82 $self->{output}->output_add(severity => $exit,
83 short_msg => sprintf("Temperature '%s' status is '%s'",
84 $instance, $result->{temperatureProbeStatus}));
85 }
86
87 if (defined($result->{temperatureProbeReading}) && $result->{temperatureProbeReading} =~ /[0-9]/) {
88 $result->{temperatureProbeReading} /= 10;
89 my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{temperatureProbeReading});
90
91 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
92 $self->{output}->output_add(severity => $exit,
93 short_msg => sprintf("Temperature '%s' is %s degree centigrade", $instance, $result->{temperatureProbeReading}));
94 }
95 $self->{output}->perfdata_add(
96 label => 'temp', unit => 'C',
97 nlabel => 'hardware.temperature.celsius',
98 instances => $instance,
99 value => $result->{temperatureProbeReading},
100 warning => $warn,
101 critical => $crit,
102 min => 0
103 );
104 }
105 }
106 }
107
108 1;