Debian Codegraph @

src/hardware/server/hp/proliant/snmp/mode/components/ilo.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::ilo;
22
23 use strict;
24 use warnings;
25
26 my %map_status = (
27 1 => 'unknown',
28 2 => 'ok',
29 3 => 'degraded',
30 4 => 'failed',
31 );
32 my %map_bitmask_status = (
33 16 => 'I2C error',
34 15 => 'EEPROM error',
35 14 => 'SRAM error',
36 13 => 'CPLD error',
37 12 => 'Mouse interface error',
38 11 => 'NIC Error',
39 10 => 'PCMCIA Error',
40 9 => 'Video Error',
41 8 => 'NVRAM write/read/verify error',
42 7 => 'NVRAM interface error',
43 6 => 'Battery interface error',
44 5 => 'Keyboard interface error',
45 4 => 'Serial port UART error',
46 3 => 'Modem UART error',
47 2 => 'Modem firmware error',
48 1 => 'Memory test error',
49 0 => 'Busmaster I/O read error',
50 );
51
52 # In MIB 'CPQSM2-MIB.mib'
53 my $mapping = {
54 cpqSm2MibCondition => { oid => '.1.3.6.1.4.1.232.9.1.3', map => \%map_status },
55 };
56 my $oid_cpqSm2CntlrSelfTestErrors = '.1.3.6.1.4.1.232.9.2.2.9';
57
58 sub load {
59 my ($self) = @_;
60
61 push @{$self->{request}}, { oid => $mapping->{cpqSm2MibCondition}->{oid} }, { oid => $oid_cpqSm2CntlrSelfTestErrors };
62 }
63
64 sub check {
65 my ($self) = @_;
66
67 $self->{output}->output_add(long_msg => "Checking ilo");
68 $self->{components}->{ilo} = {name => 'ilo', total => 0, skip => 0};
69 return if ($self->check_filter(section => 'ilo'));
70
71 return if (scalar(keys %{$self->{results}->{$mapping->{cpqSm2MibCondition}->{oid}}}) <= 0);
72 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{cpqSm2MibCondition}->{oid}}, instance => 0);
73
74 next if ($self->check_filter(section => 'ilo', instance => '0'));
75 $self->{components}->{ilo}->{total}++;
76
77 my @message_error = ();
78 if (defined($self->{results}->{$oid_cpqSm2CntlrSelfTestErrors}->{$oid_cpqSm2CntlrSelfTestErrors . '.0'})) {
79 foreach my $bit (keys %map_bitmask_status) {
80 if (int($self->{results}->{$oid_cpqSm2CntlrSelfTestErrors}->{$oid_cpqSm2CntlrSelfTestErrors . '.0'}) & (1 << ($bit))) {
81 push @message_error, $map_bitmask_status{$bit};
82 }
83 }
84 }
85
86 $self->{output}->output_add(
87 long_msg => sprintf(
88 "ilo status is %s [message = %s].",
89 $result->{cpqSm2MibCondition}, join(', ', @message_error)
90 )
91 );
92 my $exit = $self->get_severity(label => 'default', section => 'ilo', value => $result->{cpqSm2MibCondition});
93 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
94 $self->{output}->output_add(
95 severity => $exit,
96 short_msg => sprintf(
97 "ilo is %s",
98 $result->{cpqSm2MibCondition}
99 )
100 );
101 }
102 }
103
104 1;