Debian Codegraph @

src/centreon/common/violin/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 centreon::common::violin::snmp::mode::components::temperature;
22
23 use base qw(centreon::plugins::mode);
24
25 use strict;
26 use warnings;
27
28 my $oid_chassisSystemTempAmbient = '.1.3.6.1.4.1.35897.1.2.2.3.17.1.21';
29 my $oid_chassisSystemTempController = '.1.3.6.1.4.1.35897.1.2.2.3.17.1.21';
30 my $oid_arrayVimmEntry_temp = '.1.3.6.1.4.1.35897.1.2.2.3.16.1.12';
31
32 sub load {
33 my ($self) = @_;
34
35 push @{$self->{request}}, { oid => $oid_arrayVimmEntry_temp }, { oid => $oid_chassisSystemTempAmbient },
36 { oid => $oid_chassisSystemTempController };
37 }
38
39 sub temperature {
40 my ($self, %options) = @_;
41 my $oid = $options{oid};
42
43 $options{oid} =~ /^$options{oid_short}\.(.*)$/;
44 my ($dummy, $array_name, $extra_name) = $self->convert_index(value => $1);
45 my $instance = $array_name . '-' . (defined($extra_name) ? $extra_name : $options{extra_instance});
46
47 my $temperature = $options{value};
48
49 return if ($self->check_filter(section => 'temperature', instance => $instance));
50
51 $self->{components}->{temperature}->{total}++;
52 $self->{output}->output_add(long_msg => sprintf("Temperature '%s' is %s degree centigrade.",
53 $instance, $temperature));
54 my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'temperature', instance => $instance, value => $temperature);
55 $self->{output}->perfdata_add(
56 label => 'temp', unit => 'C',
57 nlabel => 'hardware.temperature.celsius',
58 instances => $instance,
59 value => $temperature,
60 warning => $warn,
61 critical => $crit
62 );
63 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
64 $self->{output}->output_add(severity => $exit,
65 short_msg => sprintf("Temperature '%s' is %s degree centigrade", $instance, $temperature));
66 }
67 }
68
69 sub check {
70 my ($self) = @_;
71
72 $self->{output}->output_add(long_msg => "Checking temperatures");
73 $self->{components}->{temperature} = {name => 'temperatures', total => 0, skip => 0};
74 return if ($self->check_filter(section => 'temperature'));
75
76 foreach my $oid (keys %{$self->{results}->{$oid_chassisSystemTempAmbient}}) {
77 temperature($self, oid => $oid, oid_short => $oid_chassisSystemTempAmbient, value => $self->{results}->{$oid_chassisSystemTempAmbient}->{$oid},
78 extra_instance => 'ambient');
79 }
80 foreach my $oid (keys %{$self->{results}->{$oid_chassisSystemTempController}}) {
81 temperature($self, oid => $oid, oid_short => $oid_chassisSystemTempController, value => $self->{results}->{$oid_chassisSystemTempController}->{$oid},
82 extra_instance => 'controller');
83 }
84 foreach my $oid (keys %{$self->{results}->{$oid_arrayVimmEntry_temp}}) {
85 temperature($self, oid => $oid, oid_short => $oid_arrayVimmEntry_temp, value => $self->{results}->{$oid_arrayVimmEntry_temp}->{$oid});
86 }
87 }
88
89 1;