Debian Codegraph @

src/storage/dell/equallogic/snmp/mode/components/psu.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::dell::equallogic::snmp::mode::components::psu;
22
23 use strict;
24 use warnings;
25
26 my %map_psu_status = (
27 1 => 'on-and-operating',
28 2 => 'no-ac-power',
29 3 => 'failed-or-no-data',
30 );
31 my %map_psufan_status = (
32 0 => 'not-applicable',
33 1 => 'fan-is-operational',
34 2 => 'fan-not-operational',
35 );
36
37 # In MIB 'eqlcontroller.mib'
38 my $mapping = {
39 eqlMemberHealthDetailsPowerSupplyName => { oid => '.1.3.6.1.4.1.12740.2.1.8.1.2' },
40 eqlMemberHealthDetailsPowerSupplyCurrentState => { oid => '.1.3.6.1.4.1.12740.2.1.8.1.3', map => \%map_psu_status },
41 eqlMemberHealthDetailsPowerSupplyFanStatus => { oid => '.1.3.6.1.4.1.12740.2.1.8.1.4', map => \%map_psufan_status },
42 };
43 my $oid_eqlMemberHealthDetailsPowerSupplyEntry = '.1.3.6.1.4.1.12740.2.1.8.1';
44
45 sub load {
46 my ($self) = @_;
47
48 push @{$self->{request}}, { oid => $oid_eqlMemberHealthDetailsPowerSupplyEntry };
49 }
50
51 sub check {
52 my ($self) = @_;
53
54 $self->{output}->output_add(long_msg => "Checking power supplies");
55 $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0};
56 return if ($self->check_filter(section => 'psu'));
57
58 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_eqlMemberHealthDetailsPowerSupplyEntry}})) {
59 next if ($oid !~ /^$mapping->{eqlMemberHealthDetailsPowerSupplyCurrentState}->{oid}\.(\d+\.\d+)\.(.*)$/);
60 my ($member_instance, $instance) = ($1, $2);
61 my $member_name = $self->get_member_name(instance => $member_instance);
62 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_eqlMemberHealthDetailsPowerSupplyEntry}, instance => $member_instance . '.' . $instance);
63
64 next if ($self->check_filter(section => 'psu', instance => $member_instance . '.' . $instance));
65 $self->{components}->{psu}->{total}++;
66
67 $self->{output}->output_add(
68 long_msg => sprintf(
69 "power supply '%s/%s' status is %s [instance: %s] [fan status: %s].",
70 $member_name, $result->{eqlMemberHealthDetailsPowerSupplyName}, $result->{eqlMemberHealthDetailsPowerSupplyCurrentState},
71 $member_instance . '.' . $instance, $result->{eqlMemberHealthDetailsPowerSupplyFanStatus}
72 )
73 );
74 my $exit = $self->get_severity(section => 'psu', value => $result->{eqlMemberHealthDetailsPowerSupplyCurrentState});
75 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
76 $self->{output}->output_add(
77 severity => $exit,
78 short_msg => sprintf(
79 "Power supply '%s/%s' status is %s",
80 $member_name, $result->{eqlMemberHealthDetailsPowerSupplyName}, $result->{eqlMemberHealthDetailsPowerSupplyCurrentState}
81 )
82 );
83 }
84
85 next if ($self->check_filter(section => 'psu.fan', instance => $member_instance . '.' . $instance));
86 $exit = $self->get_severity(section => 'psu.fan', value => $result->{eqlMemberHealthDetailsPowerSupplyFanStatus});
87 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
88 $self->{output}->output_add(
89 severity => $exit,
90 short_msg => sprintf(
91 "Power supply '%s/%s' fan status is %s",
92 $member_name, $result->{eqlMemberHealthDetailsPowerSupplyName}, $result->{eqlMemberHealthDetailsPowerSupplyFanStatus}
93 )
94 );
95 }
96 }
97 }
98
99 1;