Debian Codegraph @

src/network/atto/fibrebridge/snmp/mode/components/temperature.pm

raw
1 #
2 # Copyright 2018 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 # Author : ArnoMLT
21 #
22
23 package network::atto::fibrebridge::snmp::mode::components::temperature;
24
25 use strict;
26 use warnings;
27
28 my %map_chassis_status = (
29 1 => 'normal', 2 => 'warning', 3 => 'critical',
30 );
31 my $oid_chassisTemperatureStatus = '.1.3.6.1.4.1.4547.2.3.2.9.0';
32 my $oid_chassisTemperature = '.1.3.6.1.4.1.4547.2.3.2.8.0';
33
34 sub load {
35 my ($self) = @_;
36
37 push @{$self->{request}}, $oid_chassisTemperatureStatus, $oid_chassisTemperature;
38 }
39
40 sub check {
41 my ($self) = @_;
42
43 $self->{output}->output_add(long_msg => "checking temperatures");
44 $self->{components}->{temperature} = { name => 'temperatures', total => 0, skip => 0 };
45 return if ($self->check_filter(section => 'temperature'));
46
47 return if (!defined($self->{results}->{$oid_chassisTemperatureStatus}));
48 my ($instance, $name) = (1, 'chassis');
49 my $status = $map_chassis_status{$self->{results}->{$oid_chassisTemperatureStatus}};
50 my $temperature = $self->{results}->{$oid_chassisTemperature};
51
52 next if ($self->check_filter(section => 'temperature', instance => $instance, name => $name));
53 $self->{components}->{temperature}->{total}++;
54
55 $self->{output}->output_add(long_msg => sprintf("temperature '%s' status is %s [instance = %s, value = %s C]",
56 $name, $status, $instance, $temperature));
57 my $exit = $self->get_severity(section => 'temperature', value => $status);
58 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
59 $self->{output}->output_add(severity => $exit,
60 short_msg => sprintf("Temperature '%s' status is %s", $name, $status));
61 }
62
63 my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'temperature', instance => $instance, name => $name, value => $temperature);
64 if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
65 $self->{output}->output_add(severity => $exit2,
66 short_msg => sprintf("Temperature '%s' is %s C", $name, $temperature));
67 }
68 $self->{output}->perfdata_add(
69 label => 'temp', unit => 'C',
70 nlabel => 'hardware.temperature.celsius',
71 instances => $name,
72 value => $temperature,
73 warning => $warn,
74 critical => $crit
75 );
76 }
77
78 1;