Debian Codegraph @

src/hardware/server/hp/proliant/snmp/mode/components/fcaexternalacc.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::fcaexternalacc;
22
23 use strict;
24 use warnings;
25
26 my %map_accel_status = (
27 1 => 'other',
28 2 => 'invalid',
29 3 => 'enabled',
30 4 => 'tmpDisabled',
31 5 => 'permDisabled',
32 );
33 my %map_accel_condition = (
34 1 => 'other',
35 2 => 'ok',
36 3 => 'degraded',
37 4 => 'failed',
38 );
39 my %map_accelbattery_condition = (
40 1 => 'other',
41 2 => 'ok',
42 3 => 'recharging',
43 4 => 'failed',
44 5 => 'degraded',
45 6 => 'not present',
46 );
47
48 # In 'CPQFCA-MIB.mib'
49 my $mapping = {
50 cpqFcaAccelStatus => { oid => '.1.3.6.1.4.1.232.16.2.2.2.1.3', map => \%map_accel_status },
51 };
52 my $mapping2 = {
53 cpqFcaAccelCondition => { oid => '.1.3.6.1.4.1.232.16.2.2.2.1.9', map => \%map_accel_condition },
54 };
55 my $mapping3 = {
56 cpqFcaAccelBatteryStatus => { oid => '.1.3.6.1.4.1.232.16.2.2.2.1.6', map => \%map_accelbattery_condition },
57 };
58 my $oid_cpqFcaAccelStatus = '.1.3.6.1.4.1.232.16.2.2.2.1.3';
59 my $oid_cpqFcaAccelCondition = '.1.3.6.1.4.1.232.16.2.2.2.1.9';
60 my $oid_cpqFcaAccelBatteryStatus = '.1.3.6.1.4.1.232.16.2.2.2.1.6';
61
62 sub load {
63 my ($self) = @_;
64
65 push @{$self->{request}}, { oid => $oid_cpqFcaAccelStatus }, { oid => $oid_cpqFcaAccelCondition }, { oid => $oid_cpqFcaAccelBatteryStatus };
66 }
67
68 sub check {
69 my ($self) = @_;
70
71 $self->{output}->output_add(long_msg => "Checking fca external accelerator boards");
72 $self->{components}->{fcaexternalacc} = {name => 'fca external accelerator boards', total => 0, skip => 0};
73 return if ($self->check_filter(section => 'fcaexternalacc'));
74
75 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpqFcaAccelCondition}})) {
76 next if ($oid !~ /^$mapping->{cpqFcaAccelCondition}->{oid}\.(.*)$/);
77 my $instance = $1;
78 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpqFcaAccelStatus}, instance => $instance);
79 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cpqFcaAccelCondition}, instance => $instance);
80 my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$oid_cpqFcaAccelBatteryStatus}, instance => $instance);
81
82 next if ($self->check_filter(section => 'fcaexternalacc', instance => $instance));
83 $self->{components}->{fcaexternalacc}->{total}++;
84
85 $self->{output}->output_add(long_msg => sprintf("fca external accelerator boards '%s' [status: %s, battery status: %s] condition is %s.",
86 $instance,
87 $result->{cpqFcaAccelStatus}, $result3->{cpqFcaAccelBatteryStatus},
88 $result2->{cpqFcaAccelCondition}));
89 my $exit = $self->get_severity(label => 'default', section => 'fcaexternalacc', value => $result2->{cpqFcaAccelCondition});
90 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
91 $self->{output}->output_add(severity => $exit,
92 short_msg => sprintf("fca external accelerator boards '%s' is %s",
93 $instance, $result2->{cpqFcaAccelCondition}));
94 }
95 $exit = $self->get_severity(section => 'fcaexternalaccbattery', value => $result3->{cpqFcaAccelBatteryStatus});
96 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
97 $self->{output}->output_add(severity => $exit,
98 short_msg => sprintf("fca external accelerator boards '%s' battery is %s",
99 $instance, $result3->{cpqFcaAccelBatteryStatus}));
100 }
101 }
102 }
103
104 1;