Debian Codegraph @

src/hardware/server/ibm/bladecenter/snmp/mode/components/blower.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::blower;
22
23 use strict;
24 use warnings;
25
26 my %map_blower_state = (
27 0 => 'unknown',
28 1 => 'good',
29 2 => 'warning',
30 3 => 'bad',
31 );
32 my %map_controller_state = (
33 0 => 'operational',
34 1 => 'flashing',
35 2 => 'notPresent',
36 3 => 'communicationError',
37 255 => 'unknown',
38 );
39
40 # In MIB 'mmblade.mib'
41 my $oid_blowers = '.1.3.6.1.4.1.2.3.51.2.2.3';
42 my $entry_blower_state = '10';
43 my $entry_blower_speed = '1';
44 my $entry_controller_state = '30';
45 my $count = 4;
46
47 sub load {
48 my ($self) = @_;
49
50 push @{$self->{request}}, { oid => $oid_blowers };
51 }
52
53 sub check {
54 my ($self) = @_;
55
56 $self->{output}->output_add(long_msg => "Checking blowers");
57 $self->{components}->{blower} = {name => 'blowers', total => 0, skip => 0};
58 return if ($self->check_filter(section => 'blower'));
59
60 for (my $i = 0; $i < $count; $i++) {
61 my $instance = $i + 1;
62 next if (!defined($self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_blower_state + $i) . '.0'}));
63 my $blower_state = $map_blower_state{$self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_blower_state + $i) . '.0'}};
64 my $blower_speed = defined($self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_blower_speed + $i) . '.0'}) ? $self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_blower_speed + $i) . '.0'} : 'unknown';
65 my $ctrl_state = defined($self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_controller_state + $i) . '.0'}) ? $map_controller_state{$self->{results}->{$oid_blowers}->{$oid_blowers . '.' . ($entry_controller_state + $i) . '.0'}} : undef;
66
67 next if ($self->check_filter(section => 'blower', instance => $instance));
68 next if ($blower_speed =~ /No Blower/i &&
69 $self->absent_problem(section => 'blower', instance => $instance));
70 $self->{components}->{blower}->{total}++;
71
72 if ($blower_speed =~ /^(\d+)%/) {
73 $blower_speed = $1;
74 my ($exit2, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'blower', instance => $instance, value => $blower_speed);
75 if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
76 $self->{output}->output_add(severity => $exit2,
77 short_msg => sprintf("Blower speed '%s' is %s %%", $instance, $blower_speed));
78 }
79 $self->{output}->perfdata_add(
80 label => "blower_speed", unit => '%',
81 nlabel => 'hardware.blower.speed.percentage',
82 instances => $instance,
83 value => $blower_speed,
84 warning => $warn,
85 critical => $crit,
86 min => 0, max => 100
87 );
88 }
89
90 $self->{output}->output_add(long_msg => sprintf("Blower '%s' state is %s (%d %%).",
91 $instance, $blower_state, $blower_speed));
92 my $exit = $self->get_severity(section => 'blower', value => $blower_state);
93 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
94 $self->{output}->output_add(severity => $exit,
95 short_msg => sprintf("Blower '%s' state is %s",
96 $instance, $blower_state));
97 }
98
99 next if (!defined($ctrl_state));
100
101 next if ($self->check_filter(section => 'blowerctrl', instance => $instance));
102 next if ($ctrl_state =~ /notPresent/i &&
103 $self->absent_problem(section => 'blowerctrl', instance => $instance));
104 $self->{output}->output_add(long_msg => sprintf("Blower controller '%s' state is %s.",
105 $instance, $ctrl_state));
106 $exit = $self->get_severity(section => 'blowerctrl', value => $ctrl_state);
107 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
108 $self->{output}->output_add(severity => $exit,
109 short_msg => sprintf("Blower controller '%s' state is %s",
110 $instance, $ctrl_state));
111 }
112 }
113 }
114
115 1;