Debian Codegraph @

src/storage/netapp/ontap/snmp/mode/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 storage::netapp::ontap::snmp::mode::temperature;
22
23 use base qw(centreon::plugins::mode);
24
25 use strict;
26 use warnings;
27
28 my %mapping_temperature = (
29 1 => 'no',
30 2 => 'yes'
31 );
32
33 sub new {
34 my ($class, %options) = @_;
35 my $self = $class->SUPER::new(package => __PACKAGE__, %options);
36 bless $self, $class;
37
38 $options{options}->add_options(arguments => {
39 });
40
41 return $self;
42 }
43
44 sub check_options {
45 my ($self, %options) = @_;
46 $self->SUPER::init(%options);
47 }
48
49 sub run {
50 my ($self, %options) = @_;
51 $self->{snmp} = $options{snmp};
52
53 my $oid_envOverTemperature = '.1.3.6.1.4.1.789.1.2.4.1';
54 my $oid_nodeName = '.1.3.6.1.4.1.789.1.25.2.1.1';
55 my $oid_nodeEnvOverTemperature = '.1.3.6.1.4.1.789.1.25.2.1.18';
56 my $results = $self->{snmp}->get_multiple_table(
57 oids => [
58 { oid => $oid_envOverTemperature },
59 { oid => $oid_nodeName },
60 { oid => $oid_nodeEnvOverTemperature }
61 ],
62 nothing_quit => 1
63 );
64
65 if (defined($results->{$oid_envOverTemperature}->{$oid_envOverTemperature . '.0'})) {
66 $self->{output}->output_add(
67 severity => 'OK',
68 short_msg => 'Hardware temperature is ok.'
69 );
70 if ($mapping_temperature{$results->{$oid_envOverTemperature}->{$oid_envOverTemperature . '.0'}} eq 'yes') {
71 $self->{output}->output_add(
72 severity => 'CRITICAL',
73 short_msg => 'Hardware temperature is over temperature range.'
74 );
75 }
76 } else {
77 $self->{output}->output_add(
78 severity => 'OK',
79 short_msg => 'Hardware temperature are ok on all nodes'
80 );
81 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$results->{$oid_nodeEnvOverTemperature}})) {
82 $oid =~ /^$oid_nodeEnvOverTemperature\.(.*)$/;
83 my $instance = $1;
84 my $name = $results->{$oid_nodeName}->{$oid_nodeName . '.' . $instance};
85 my $temp = $results->{$oid_nodeEnvOverTemperature}->{$oid};
86 $self->{output}->output_add(
87 long_msg => sprintf(
88 "hardware temperature on node '%s' is over range: '%s'",
89 $name, $mapping_temperature{$temp}
90 )
91 );
92 if ($mapping_temperature{$temp} eq 'yes') {
93 $self->{output}->output_add(
94 severity => 'CRITICAL',
95 short_msg => sprintf("Hardware temperature is over temperature range on node '%s'", $name)
96 );
97 }
98 }
99 }
100
101 $self->{output}->display();
102 $self->{output}->exit();
103 }
104
105 1;
106
107 __END__
108
109 =head1 MODE
110
111 Check if hardware is currently operating outside of its recommended temperature range.
112
113 =over 8
114
115 =back
116
117 =cut
118