Debian Codegraph @

src/network/nortel/standard/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 network::nortel::standard::snmp::mode::components::temperature;
22
23 use strict;
24 use warnings;
25
26 my $mapping_s5 = {
27 value => { oid => '.1.3.6.1.4.1.45.1.6.3.7.1.1.5' } # s5ChasTmpSnrTmpValue
28 };
29 my $oid_s5ChasTmpSnrEntry = '.1.3.6.1.4.1.45.1.6.3.7.1.1';
30
31 my $mapping_voss = {
32 description => { oid => '.1.3.6.1.4.1.2272.1.101.1.1.2.1.2' }, # rcVossSystemTemperatureSensorDescription
33 value => { oid => '.1.3.6.1.4.1.2272.1.101.1.1.2.1.3' } # rcVossSystemTemperatureTemperature
34 };
35 my $oid_vossTempEntry = '.1.3.6.1.4.1.2272.1.101.1.1.2.1'; # rcVossSystemTemperatureEntry
36
37 sub load {
38 my ($self) = @_;
39
40 push @{$self->{request}},
41 { oid => $oid_s5ChasTmpSnrEntry, start => $mapping_s5->{value}->{oid}, end => $mapping_s5->{value}->{oid} },
42 { oid => $oid_vossTempEntry, start => $mapping_voss->{description}->{oid}, end => $mapping_voss->{value}->{oid} };
43 }
44
45 sub check_s5 {
46 my ($self) = @_;
47
48 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_s5ChasTmpSnrEntry}})) {
49 next if ($oid !~ /^$mapping_s5->{value}->{oid}\.(.*)$/);
50 my $instance = $1;
51 my $result = $self->{snmp}->map_instance(mapping => $mapping_s5, results => $self->{results}->{$oid_s5ChasTmpSnrEntry}, instance => $instance);
52
53 next if ($self->check_filter(section => 'temperature', instance => $instance));
54 $self->{components}->{temperature}->{total}++;
55
56 $result->{value} = sprintf("%.2f", $result->{value} / 2);
57 $self->{output}->output_add(
58 long_msg => sprintf(
59 "temperature '%s' is %s degree centigrade [instance: %s]",
60 $instance, $result->{value}, $instance
61 )
62 );
63
64 my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{value});
65 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
66 $self->{output}->output_add(
67 severity => $exit,
68 short_msg => sprintf(
69 "Temperature '%s' is %s degree centigrade", $instance, $result->{value}
70 )
71 );
72 }
73 $self->{output}->perfdata_add(
74 nlabel => 'hardware.temperature.celsius',
75 unit => 'C',
76 instances => $instance,
77 value => $result->{value},
78 warning => $warn,
79 critical => $crit
80 );
81 }
82 }
83
84 sub check_voss {
85 my ($self) = @_;
86
87 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_vossTempEntry}})) {
88 next if ($oid !~ /^$mapping_voss->{value}->{oid}\.(.*)$/);
89 my $instance = $1;
90 my $result = $self->{snmp}->map_instance(mapping => $mapping_voss, results => $self->{results}->{$oid_vossTempEntry}, instance => $instance);
91
92 next if ($self->check_filter(section => 'temperature', instance => $instance));
93 $self->{components}->{temperature}->{total}++;
94
95 $self->{output}->output_add(
96 long_msg => sprintf(
97 "temperature '%s' is %s degree centigrade [instance: %s]",
98 $result->{description}, $result->{value}, $instance
99 )
100 );
101
102 my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $result->{value});
103 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
104 $self->{output}->output_add(
105 severity => $exit,
106 short_msg => sprintf(
107 "Temperature '%s' is %s degree centigrade", $result->{description}, $result->{value}
108 )
109 );
110 }
111 $self->{output}->perfdata_add(
112 nlabel => 'hardware.temperature.celsius',
113 unit => 'C',
114 instances => $result->{description},
115 value => $result->{value},
116 warning => $warn,
117 critical => $crit
118 );
119 }
120 }
121
122 sub check {
123 my ($self) = @_;
124
125 $self->{output}->output_add(long_msg => "Checking temperatures");
126 $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
127 return if ($self->check_filter(section => 'temperature'));
128
129 check_s5($self);
130 check_voss($self);
131 }
132
133 1;