Debian Codegraph @

src/hardware/server/hp/bladechassis/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::bladechassis::snmp::mode::components::psu;
22
23 use strict;
24 use warnings;
25
26 my %map_conditions = (
27 1 => 'other',
28 2 => 'ok',
29 3 => 'degraded',
30 4 => 'failed',
31 );
32
33 my %present_map = (
34 1 => 'other',
35 2 => 'absent',
36 3 => 'present',
37 4 => 'Weird!!!', # for blades it can return 4, which is NOT spesified in MIB
38 );
39
40 my %psu_status_map = (
41 1 => 'noError',
42 2 => 'generalFailure',
43 3 => 'bistFailure',
44 4 => 'fanFailure',
45 5 => 'tempFailure',
46 6 => 'interlockOpen',
47 7 => 'epromFailed',
48 8 => 'vrefFailed',
49 9 => 'dacFailed',
50 10 => 'ramTestFailed',
51 11 => 'voltageChannelFailed',
52 12 => 'orringdiodeFailed',
53 13 => 'brownOut',
54 14 => 'giveupOnStartup',
55 15 => 'nvramInvalid',
56 16 => 'calibrationTableInvalid',
57 );
58 my %inputline_status_map = (
59 1 => 'noError',
60 2 => 'lineOverVoltage',
61 3 => 'lineUnderVoltage',
62 4 => 'lineHit',
63 5 => 'brownOut',
64 6 => 'linePowerLoss',
65 );
66
67 my $mapping = {
68 psu_status => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.14', map => \%psu_status_map }, # cpqRackPowerSupplyStatus
69 psu_serial => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.5' }, # cpqRackPowerSupplySerialNum
70 psu_part => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.6' }, # cpqRackPowerSupplyPartNumber
71 psu_spare => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.7' }, # cpqRackPowerSupplySparePartNumber
72 psu_inputlinestatus => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.15', map => \%inputline_status_map }, # cpqRackPowerSupplyInputLineStatus
73 psu_condition => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.17', map => \%map_conditions }, # cpqRackPowerSupplyCondition
74 psu_pwrout => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.10' }, # cpqRackPowerSupplyCurPwrOutput in Watts
75 psu_intemp => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.12' }, # cpqRackPowerSupplyIntakeTemp
76 psu_exhtemp => { oid => '.1.3.6.1.4.1.232.22.2.5.1.1.1.13' }, # cpqRackPowerSupplyExhaustTemp
77 };
78
79 sub check {
80 my ($self) = @_;
81
82 # We dont check 'cpqRackPowerEnclosureTable' (the overall power system status)
83 # We check 'cpqRackPowerSupplyTable' (unitary)
84
85 $self->{components}->{psu} = {name => 'power supplies', total => 0, skip => 0};
86 $self->{output}->output_add(long_msg => "checking power supplies");
87 return if ($self->check_filter(section => 'psu'));
88
89 my $oid_cpqRackPowerSupplyPresent = '.1.3.6.1.4.1.232.22.2.5.1.1.1.16';
90
91 my $snmp_result = $self->{snmp}->get_table(oid => $oid_cpqRackPowerSupplyPresent);
92 return if (scalar(keys %$snmp_result) <= 0);
93 my @get_oids = ();
94 my @oids_end = ();
95 foreach my $key ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) {
96 $key =~ /^$oid_cpqRackPowerSupplyPresent\.(.*)$/;
97 my $oid_end = $1;
98
99 next if ($present_map{$snmp_result->{$key}} ne 'present' &&
100 $self->absent_problem(section => 'psu', instance => $oid_end));
101
102 push @oids_end, $oid_end;
103 push @get_oids, map($_->{oid} . '.' . $oid_end, values(%$mapping));
104 }
105
106 $snmp_result = $self->{snmp}->get_leef(oids => \@get_oids);
107 my $total_watts = 0;
108 foreach (@oids_end) {
109 my $psu_index = $_;
110 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_);
111
112 next if ($self->check_filter(section => 'psu', instance => $psu_index));
113
114 $total_watts += $result->{psu_pwrout};
115 $self->{components}->{psu}->{total}++;
116 $self->{output}->output_add(
117 long_msg => sprintf("psu '%s' status is %s [serial: %s, part: %s, spare: %s] (input line status %s) (status %s).",
118 $psu_index, $result->{psu_condition},
119 $result->{psu_serial}, $result->{psu_part}, $result->{psu_spare},
120 $result->{psu_inputlinestatus},
121 $result->{psu_status}
122 )
123 );
124
125 my $exit = $self->get_severity(label => 'default', section => 'psu', instance => $psu_index, value => $result->{psu_condition});
126 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
127 $self->{output}->output_add(severity => $exit,
128 short_msg => sprintf("PSU '%s' status is %s",
129 $psu_index, $result->{psu_condition}));
130 }
131
132 $self->{output}->perfdata_add(
133 label => 'psu_power', unit => 'W',
134 nlabel => 'hardware.powersupply.power.watt',
135 instances => $psu_index,
136 value => $result->{psu_pwrout}
137 );
138 if (defined($result->{psu_intemp}) && $result->{psu_intemp} != -1) {
139 $self->{output}->perfdata_add(
140 label => 'psu_temp', unit => 'C',
141 nlabel => 'hardware.powersupply.temperature.celsius',
142 instances => [$psu_index, 'intake'],
143 value => $result->{psu_intemp}
144 );
145 }
146 if (defined($result->{psu_exhtemp}) && $result->{psu_exhtemp} != -1) {
147 $self->{output}->perfdata_add(
148 label => 'psu_temp', unit => 'C',
149 nlabel => 'hardware.powersupply.temperature.celsius',
150 instances => [$psu_index, 'exhaust'],
151 value => $result->{psu_exhtemp}
152 );
153 }
154 }
155
156 $self->{output}->perfdata_add(
157 label => 'total_power', unit => 'W',
158 nlabel => 'hardware.powersupply.power.watt',
159 value => $total_watts
160 );
161 }
162
163 1;