Debian Codegraph @

src/hardware/server/hp/proliant/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 hardware::server::hp::proliant::snmp::mode::components::psu;
22
23 use strict;
24 use warnings;
25
26 my %map_psu_condition = (
27 1 => 'other',
28 2 => 'ok',
29 3 => 'degraded',
30 4 => 'failed',
31 );
32
33 my %map_present = (
34 1 => 'other',
35 2 => 'absent',
36 3 => 'present',
37 );
38
39 my %map_redundant = (
40 1 => 'other',
41 2 => 'not redundant',
42 3 => 'redundant',
43 );
44
45 my %map_psu_status = (
46 1 => 'noError',
47 2 => 'generalFailure',
48 3 => 'bistFailure',
49 4 => 'fanFailure',
50 5 => 'tempFailure',
51 6 => 'interlockOpen',
52 7 => 'epromFailed',
53 8 => 'vrefFailed',
54 9 => 'dacFailed',
55 10 => 'ramTestFailed',
56 11 => 'voltageChannelFailed',
57 12 => 'orringdiodeFailed',
58 13 => 'brownOut',
59 14 => 'giveupOnStartup',
60 15 => 'nvramInvalid',
61 16 => 'calibrationTableInvalid',
62 );
63
64 # In MIB 'CPQHLTH-MIB.mib'
65 my $mapping = {
66 cpqHeFltTolPowerSupplyPresent => { oid => '.1.3.6.1.4.1.232.6.2.9.3.1.3', map => \%map_present },
67 cpqHeFltTolPowerSupplyCondition => { oid => '.1.3.6.1.4.1.232.6.2.9.3.1.4', map => \%map_psu_condition },
68 cpqHeFltTolPowerSupplyStatus => { oid => '.1.3.6.1.4.1.232.6.2.9.3.1.5', map => \%map_psu_status },
69 cpqHeFltTolPowerSupplyMainVoltage => { oid => '.1.3.6.1.4.1.232.6.2.9.3.1.6' },
70 cpqHeFltTolPowerSupplyCapacityUsed => { oid => '.1.3.6.1.4.1.232.6.2.9.3.1.7' },
71 cpqHeFltTolPowerSupplyCapacityMaximum => { oid => '.1.3.6.1.4.1.232.6.2.9.3.1.8' },
72 cpqHeFltTolPowerSupplyRedundant => { oid => '.1.3.6.1.4.1.232.6.2.9.3.1.9' },
73 };
74 my $mapping2 = {
75 cpqHeFltTolPowerSupplyRedundantPartner => { oid => '.1.3.6.1.4.1.232.6.2.9.3.1.17' },
76 };
77 my $oid_cpqHeFltTolPowerSupplyEntry = '.1.3.6.1.4.1.232.6.2.9.3.1';
78 my $oid_cpqHeFltTolPowerSupplyRedundantPartner = '.1.3.6.1.4.1.232.6.2.9.3.1.17';
79
80 sub load {
81 my ($self) = @_;
82
83 push @{$self->{request}}, { oid => $oid_cpqHeFltTolPowerSupplyEntry, start => $mapping->{cpqHeFltTolPowerSupplyPresent}->{oid}, end => $mapping->{cpqHeFltTolPowerSupplyRedundant}->{oid} },
84 { oid => $oid_cpqHeFltTolPowerSupplyRedundantPartner };
85 }
86
87 sub check {
88 my ($self) = @_;
89
90 $self->{output}->output_add(long_msg => "Checking power supplies");
91 $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0};
92 return if ($self->check_filter(section => 'psu'));
93
94 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpqHeFltTolPowerSupplyEntry}})) {
95 next if ($oid !~ /^$mapping->{cpqHeFltTolPowerSupplyPresent}->{oid}\.(.*)$/);
96 my $instance = $1;
97 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpqHeFltTolPowerSupplyEntry}, instance => $instance);
98 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cpqHeFltTolPowerSupplyRedundantPartner}, instance => $instance);
99
100 next if ($self->check_filter(section => 'psu', instance => $instance));
101 next if ($result->{cpqHeFltTolPowerSupplyPresent} !~ /present/i &&
102 $self->absent_problem(section => 'psu', instance => $instance));
103 $self->{components}->{psu}->{total}++;
104
105 $self->{output}->output_add(long_msg => sprintf("powersupply '%s' status is %s [redundance: %s, redundant partner: %s] (status %s).",
106 $instance, $result->{cpqHeFltTolPowerSupplyCondition},
107 $result->{cpqHeFltTolPowerSupplyRedundant},
108 defined($result2->{cpqHeFltTolPowerSupplyRedundantPartner}) ? $result2->{cpqHeFltTolPowerSupplyRedundantPartner} : 'unknown',
109 $result->{cpqHeFltTolPowerSupplyStatus}
110 ));
111 my $exit = $self->get_severity(label => 'default', section => 'psu', value => $result->{cpqHeFltTolPowerSupplyCondition});
112 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
113 $self->{output}->output_add(severity => $exit,
114 short_msg => sprintf("powersupply '%s' status is %s",
115 $instance, $result->{cpqHeFltTolPowerSupplyCondition}));
116 }
117
118 $self->{output}->perfdata_add(
119 unit => 'W',
120 nlabel => 'hardware.powersupply.power.watt',
121 instances => $instance,
122 value => $result->{cpqHeFltTolPowerSupplyCapacityUsed},
123 critical => $result->{cpqHeFltTolPowerSupplyCapacityMaximum}
124 );
125 $self->{output}->perfdata_add(
126 unit => 'V',
127 nlabel => 'hardware.powersupply.voltage.volt',
128 instances => $instance,
129 value => $result->{cpqHeFltTolPowerSupplyMainVoltage}
130 );
131 }
132 }
133
134 1;