Debian Codegraph @

src/storage/netapp/ontap/snmp/mode/components/fan.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::components::fan;
22
23 use base qw(centreon::plugins::mode);
24
25 use strict;
26 use warnings;
27
28 my $oid_enclChannelShelfAddr = '.1.3.6.1.4.1.789.1.21.1.2.1.3';
29 my $oid_enclFansPresent = '.1.3.6.1.4.1.789.1.21.1.2.1.17';
30 my $oid_enclFansFailed = '.1.3.6.1.4.1.789.1.21.1.2.1.18';
31 my $oid_enclFansSpeed = '.1.3.6.1.4.1.789.1.21.1.2.1.62';
32
33 sub load {
34 my ($self) = @_;
35
36 push @{$self->{request}}, { oid => $oid_enclFansPresent }, { oid => $oid_enclFansFailed },
37 { oid => $oid_enclFansSpeed };
38 }
39
40 sub check {
41 my ($self) = @_;
42
43 $self->{output}->output_add(long_msg => "Checking fans");
44 $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
45 return if ($self->check_filter(section => 'fan'));
46
47 for (my $i = 1; $i <= $self->{number_shelf}; $i++) {
48 my $shelf_addr = $self->{shelf_addr}->{$oid_enclChannelShelfAddr . '.' . $i};
49 my $present = $self->{results}->{$oid_enclFansPresent}->{$oid_enclFansPresent . '.' . $i};
50 my $failed = $self->{results}->{$oid_enclFansFailed}->{$oid_enclFansFailed . '.' . $i};
51 my @current_speed = defined($self->{results}->{$oid_enclFansSpeed}->{$oid_enclFansSpeed . '.' . $i}) ? split /,/, $self->{results}->{$oid_enclFansSpeed}->{$oid_enclFansSpeed . '.' . $i} : ();
52
53 foreach my $num (split /,/, $present) {
54 $num = centreon::plugins::misc::trim($num);
55 next if ($num !~ /[0-9]/);
56 my $current_value = (defined($current_speed[$num - 1]) && $current_speed[$num - 1] =~ /(^|\s)([0-9]+)/) ? $2 : '';
57
58 next if ($self->check_filter(section => 'fan', instance => $shelf_addr . '.' . $num));
59 $self->{components}->{fan}->{total}++;
60
61 my $status = 'ok';
62 if ($failed =~ /(^|,|\s)$num(,|\s|$)/) {
63 $status = 'failed';
64 }
65
66 $self->{output}->output_add(long_msg => sprintf("Shelve '%s' Fan '%s' is '%s'",
67 $shelf_addr, $num, $status));
68 my $exit = $self->get_severity(section => 'fan', value => $status);
69 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
70 $self->{output}->output_add(severity => $exit,
71 short_msg => sprintf("Shelve '%s' Fan '%s' is '%s'", $shelf_addr, $num, $status));
72 }
73
74 if ($current_value ne '') {
75 my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'fan', instance => $shelf_addr . '.' . $num, value => $current_value);
76 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
77 $self->{output}->output_add(severity => $exit,
78 short_msg => sprintf("Shelve '%s' Fan '%s' speed is '%s'", $shelf_addr, $num, $current_value));
79 }
80
81 $self->{output}->perfdata_add(
82 label => "speed", unit => 'rpm',
83 nlabel => 'hardware.fan.speed.rpm',
84 instances => [$shelf_addr, $num],
85 value => $current_value,
86 warning => $warn,
87 critical => $crit,
88 min => 0
89 );
90 }
91 }
92 }
93 }
94
95 1;