Debian Codegraph @

src/hardware/server/ibm/bladecenter/snmp/mode/components/fanpack.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 hardware::server::ibm::bladecenter::snmp::mode::components::fanpack;
22
23 use strict;
24 use warnings;
25
26 my %map_state = (
27 0 => 'unknown',
28 1 => 'good',
29 2 => 'warning',
30 3 => 'bad',
31 );
32 my %map_exists = (
33 0 => 'false',
34 1 => 'true',
35 );
36
37 # In MIB 'mmblade.mib' and 'cme.mib'
38 my $mapping = {
39 fanPackExists => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.2', map => \%map_exists },
40 fanPackState => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.3', map => \%map_state },
41 fanPackAverageSpeedRPM => { oid => '.1.3.6.1.4.1.2.3.51.2.2.6.1.1.6' },
42 };
43 my $oid_fanPackEntry = '.1.3.6.1.4.1.2.3.51.2.2.6.1.1';
44
45 sub load {
46 my ($self) = @_;
47
48 push @{$self->{request}}, { oid => $oid_fanPackEntry };
49 }
50
51 sub check {
52 my ($self) = @_;
53
54 $self->{output}->output_add(long_msg => "Checking fanpack");
55 $self->{components}->{fanpack} = {name => 'fanpacks', total => 0, skip => 0};
56 return if ($self->check_filter(section => 'fanpack'));
57
58 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_fanPackEntry}})) {
59 next if ($oid !~ /^$mapping->{fanPackState}->{oid}\.(.*)$/);
60 my $instance = $1;
61 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_fanPackEntry}, instance => $instance);
62
63 if ($result->{fanPackExists} =~ /false/i) {
64 $self->{output}->output_add(long_msg => "skipping fanpack '" . $instance . "' : not exits");
65 next;
66 }
67 next if ($self->check_filter(section => 'fanpack', instance => $instance));
68 $self->{components}->{fanpack}->{total}++;
69
70 $self->{output}->output_add(long_msg => sprintf("Fanpack '%s' is %s rpm [status: %s, instance: %s]",
71 $instance, $result->{fanPackAverageSpeedRPM}, $result->{fanPackState},
72 $instance));
73 my $exit = $self->get_severity(section => 'fanpack', value => $result->{fanPackState});
74 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
75 $self->{output}->output_add(severity => $exit,
76 short_msg => sprintf("Fanpack '%s' status is %s",
77 $instance, $result->{fanPackState}));
78 }
79
80 if (defined($result->{fanPackAverageSpeedRPM}) && $result->{fanPackAverageSpeedRPM} =~ /[0-9]/) {
81 my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fanpack', instance => $instance, value => $result->{fanPackAverageSpeedRPM});
82 if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
83 $self->{output}->output_add(severity => $exit2,
84 short_msg => sprintf("Fanpack '%s' speed is %s rpm", $instance, $result->{fanPackAverageSpeedRPM}));
85 }
86 $self->{output}->perfdata_add(
87 label => "fanpack", unit => 'rpm',
88 nlabel => 'hardware.fanpack.speed.rpm',
89 instances => $instance,
90 value => $result->{fanPackAverageSpeedRPM},
91 warning => $warn,
92 critical => $crit,
93 min => 0
94 );
95 }
96 }
97 }
98
99 1;