Debian Codegraph @

src/hardware/server/ibm/bladecenter/snmp/mode/components/ambient.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::ibm::bladecenter::snmp::mode::components::ambient;
22
23 use strict;
24 use warnings;
25
26
27 my $oid_temperature = '.1.3.6.1.4.1.2.3.51.2.2.1';
28 my $oid_end = '.1.3.6.1.4.1.2.3.51.2.2.1.5';
29 my $oid_rearLEDCardTempMax = '.1.3.6.1.4.1.2.3.51.2.2.1.5.3.0';
30 # In MIB 'mmblade.mib' and 'cme.mib'
31 my $oids = {
32 bladecenter => {
33 mm => '.1.3.6.1.4.1.2.3.51.2.2.1.1.2.0',
34 frontpanel => '.1.3.6.1.4.1.2.3.51.2.2.1.5.1.0',
35 frontpanel2 => '.1.3.6.1.4.1.2.3.51.2.2.1.5.2.0',
36 },
37 pureflex => {
38 ambient => '.1.3.6.1.4.1.2.3.51.2.2.1.5.1.0', # rearLEDCardTempAvg
39 }
40 };
41
42 sub load {
43 my ($self) = @_;
44
45 push @{$self->{request}}, { oid => $oid_temperature, end => $oid_end };
46 }
47
48 sub check {
49 my ($self) = @_;
50
51 $self->{output}->output_add(long_msg => "Checking ambient");
52 $self->{components}->{ambient} = {name => 'ambient', total => 0, skip => 0};
53 return if ($self->check_filter(section => 'ambient'));
54
55 my @sensors = ('mm', 'frontpanel', 'frontpanel2');
56 my $label = 'bladecenter';
57 if (defined($self->{results}->{$oid_temperature}->{$oid_rearLEDCardTempMax})) {
58 @sensors = ('ambient');
59 $label = 'pureflex';
60 }
61
62 foreach my $temp (@sensors) {
63 if (!defined($self->{results}->{$oid_temperature}->{$oids->{$label}->{$temp}}) ||
64 $self->{results}->{$oid_temperature}->{$oids->{$label}->{$temp}} !~ /([0-9\.]+)/) {
65 $self->{output}->output_add(long_msg => sprintf("skip ambient '%s': no values",
66 $temp));
67 next;
68 }
69
70 my $value = $1;
71 next if ($self->check_filter(section => 'ambient', instance => $temp));
72 $self->{components}->{ambient}->{total}++;
73
74 $self->{output}->output_add(long_msg => sprintf("ambient '%s' is %s degree centigrade.",
75 $temp, $value));
76 my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'ambient', instance => $temp, value => $value);
77 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
78 $self->{output}->output_add(severity => $exit,
79 short_msg => sprintf("ambient '%s' is %s degree centigrade",
80 $temp, $value));
81 }
82 $self->{output}->perfdata_add(
83 label => 'temp', unit => 'C',
84 nlabel => 'hardware.ambient.temperature.celsius',
85 instances => $temp,
86 value => $value,
87 warning => $warn,
88 critical => $crit
89 );
90 }
91 }
92
93 1;