Debian Codegraph @

src/storage/ibm/fs900/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::ibm::fs900::snmp::mode::components::fan;
22
23 use strict;
24 use warnings;
25
26 # In MIB 'IBM-FLASHSYSTEM.MIB'
27 my $mapping = {
28 fanObject => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.2' },
29 fanPWM => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.4' },
30 fanTemp => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.5' },
31 fan0 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.6' },
32 fan1 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.7' },
33 fan2 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.8' },
34 fan3 => { oid => '.1.3.6.1.4.1.2.6.255.1.1.6.10.1.9' },
35 };
36 my $oid_fanTableEntry = '.1.3.6.1.4.1.2.6.255.1.1.6.10.1';
37
38 sub load {
39 my ($self) = @_;
40
41 push @{$self->{request}}, { oid => $oid_fanTableEntry };
42 }
43
44 sub check {
45 my ($self) = @_;
46
47 $self->{output}->output_add(long_msg => "Checking fan modules");
48 $self->{components}->{fan} = {name => 'fans', total => 0, skip => 0};
49 return if ($self->check_filter(section => 'fan'));
50
51 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanTableEntry}})) {
52 next if ($oid !~ /^$mapping->{fanObject}->{oid}\.(.*)$/);
53 my $instance = $1;
54 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanTableEntry}, instance => $instance);
55
56 next if ($self->check_filter(section => 'fan', instance => $instance));
57
58 $self->{components}->{fan}->{total}++;
59 $self->{output}->output_add(long_msg => sprintf("Fan module '%s' [instance = %s, PWM = %s%%, temperature = %sC, fan0 speed = %s%%, fan1 speed = %s%%, fan2 speed = %s%%, fan3 speed = %s%%]",
60 $result->{fanObject}, $instance, $result->{fanPWM}, $result->{fanTemp} / 10, $result->{fan0}, $result->{fan1}, $result->{fan2}, $result->{fan3}));
61
62
63 if (defined($result->{fanPWM}) && $result->{fanPWM} =~ /[0-9]/) {
64 my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'fan.pwm', instance => $instance, value => $result->{fanPWM});
65 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
66 $self->{output}->output_add(severity => $exit,
67 short_msg => sprintf("Fan module '%s' PWM is %s%", $instance, $result->{fanPWM}));
68 }
69 $self->{output}->perfdata_add(
70 label => 'fan_pwm', unit => '%',
71 nlabel => 'hardware.fan.pwm.percentage',
72 instances => $instance,
73 value => $result->{fanPWM},
74 warning => $warn,
75 critical => $crit,
76 min => 0, max => 100,
77 );
78 }
79
80 if (defined($result->{fanTemp}) && $result->{fanTemp} =~ /[0-9]/) {
81 my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'fan.temperature', instance => $instance, value => $result->{fanTemp} / 10);
82 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
83 $self->{output}->output_add(severity => $exit,
84 short_msg => sprintf("Fan module '%s' temperature is %s degree centigrade", $instance, $result->{fanTemp} / 10));
85 }
86 $self->{output}->perfdata_add(
87 label => 'fan_temp', unit => 'C',
88 nlabel => 'hardware.fan.temperature.celsius',
89 instances => $instance,
90 value => $result->{fanTemp} / 10,
91 warning => $warn,
92 critical => $crit,
93 min => 0,
94 );
95 }
96
97 foreach my $fan ('fan0', 'fan1', 'fan2', 'fan3') {
98 if (defined($result->{$fan}) && $result->{$fan} =~ /[0-9]/) {
99 my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'fan.speed', instance => $instance, value => $result->{$fan});
100 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
101 $self->{output}->output_add(severity => $exit,
102 short_msg => sprintf("Fan module '%s' fan '%s' speed is %s%%", $instance, $fan, $result->{$fan}));
103 }
104 $self->{output}->perfdata_add(
105 label => 'fan_speed', unit => '%',
106 nlabel => 'hardware.fan.speed.percentage',
107 instances => [$instance, $fan],
108 value => $result->{$fan},
109 warning => $warn,
110 critical => $crit,
111 min => 0, max => 100,
112 );
113 }
114 }
115 }
116 }
117
118 1;