Debian Codegraph @

src/network/nokia/isam/snmp/mode/components/cardtemperature.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 network::nokia::isam::snmp::mode::components::cardtemperature;
22
23 use strict;
24 use warnings;
25 use network::nokia::isam::snmp::mode::components::resources qw($mapping_slot);
26
27 my $oid_eqptBoardThermalSensorActualTemperature = '.1.3.6.1.4.1.637.61.1.23.10.1.2';
28
29 sub load {
30 my ($self) = @_;
31
32 push @{$self->{request}}, { oid => $oid_eqptBoardThermalSensorActualTemperature };
33 }
34
35 sub check {
36 my ($self) = @_;
37
38 $self->{output}->output_add(long_msg => "Checking card temperatures");
39 $self->{components}->{cardtemperature} = {name => 'card temperatures', total => 0, skip => 0};
40 return if ($self->check_filter(section => 'cardtemperature'));
41
42 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqptBoardThermalSensorActualTemperature}})) {
43 $oid =~ /^$oid_eqptBoardThermalSensorActualTemperature\.(.*?)\.(.*?)$/;
44 my ($slot_id, $thermal_id) = ($1, $2);
45
46 my $temperature = $self->{results}->{$oid_eqptBoardThermalSensorActualTemperature}->{$oid};
47 my $result = $self->{snmp}->map_instance(mapping => $mapping_slot, results =>
48 { %{$self->{results}->{$mapping_slot->{eqptSlotActualType}->{oid}}}, %{$self->{results}->{$mapping_slot->{eqptBoardInventorySerialNumber}->{oid}}} }, instance => $slot_id);
49
50 next if ($self->check_filter(section => 'cardtemperature', instance => $slot_id . '.' . $thermal_id));
51
52 my $name = $result->{eqptSlotActualType} . '/' . $result->{eqptBoardInventorySerialNumber} . '/' . $thermal_id;
53 $self->{components}->{cardtemperature}->{total}++;
54 $self->{output}->output_add(long_msg => sprintf("card '%s' temperature is %s C [instance = %s]",
55 $name, $temperature, $slot_id . '.' . $thermal_id));
56
57 my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'cardtemperature', instance => $slot_id . '.' . $thermal_id, value => $temperature);
58 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
59 $self->{output}->output_add(severity => $exit,
60 short_msg => sprintf("Card '%s' temperature is %s C", $name, $temperature));
61 }
62 $self->{output}->perfdata_add(
63 label => 'cardtemperature', unit => 'C',
64 nlabel => 'hardware.card.temperature.celsius',
65 instances => $name,
66 value => $temperature,
67 warning => $warn,
68 critical => $crit
69 );
70 }
71 }
72
73 1;