Debian Codegraph @

src/hardware/server/hp/proliant/snmp/mode/components/dapdrive.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::dapdrive;
22
23 use strict;
24 use warnings;
25
26 my %map_dapdrive_condition = (
27 1 => 'other',
28 2 => 'ok',
29 3 => 'degraded',
30 4 => 'failed',
31 );
32 my %map_dapdrive_status = (
33 1 => 'other',
34 2 => 'ok',
35 3 => 'failed',
36 4 => 'predictiveFailure',
37 5 => 'erasing',
38 6 => 'eraseDone',
39 7 => 'eraseQueued',
40 );
41 # In 'CPQIDA-MIB.mib'
42 my $mapping = {
43 cpqDaPhyDrvStatus => { oid => '.1.3.6.1.4.1.232.3.2.5.1.1.6', map => \%map_dapdrive_status },
44 };
45 my $mapping2 = {
46 cpqDaPhyDrvCondition => { oid => '.1.3.6.1.4.1.232.3.2.5.1.1.37', map => \%map_dapdrive_condition },
47 };
48 my $oid_cpqDaPhyDrvCondition = '.1.3.6.1.4.1.232.3.2.5.1.1.37';
49 my $oid_cpqDaPhyDrvStatus = '.1.3.6.1.4.1.232.3.2.5.1.1.6';
50
51 sub load {
52 my ($self) = @_;
53
54 push @{$self->{request}}, { oid => $oid_cpqDaPhyDrvStatus }, { oid => $oid_cpqDaPhyDrvCondition };
55 }
56
57 sub check {
58 my ($self) = @_;
59
60 $self->{output}->output_add(long_msg => "Checking da physical drives");
61 $self->{components}->{dapdrive} = {name => 'da physical drives', total => 0, skip => 0};
62 return if ($self->check_filter(section => 'dapdrive'));
63
64 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpqDaPhyDrvCondition}})) {
65 next if ($oid !~ /^$mapping2->{cpqDaPhyDrvCondition}->{oid}\.(.*)$/);
66 my $instance = $1;
67 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpqDaPhyDrvStatus}, instance => $instance);
68 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cpqDaPhyDrvCondition}, instance => $instance);
69
70 next if ($self->check_filter(section => 'dapdrive', instance => $instance));
71 $self->{components}->{dapdrive}->{total}++;
72
73 $self->{output}->output_add(long_msg => sprintf("da physical drive '%s' [status: %s] condition is %s.",
74 $instance,
75 $result->{cpqDaPhyDrvStatus},
76 $result2->{cpqDaPhyDrvCondition}));
77 my $exit = $self->get_severity(label => 'default', section => 'dapdrive', value => $result2->{cpqDaPhyDrvCondition});
78 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
79 $self->{output}->output_add(severity => $exit,
80 short_msg => sprintf("da physical drive '%s' is %s",
81 $instance, $result2->{cpqDaPhyDrvCondition}));
82 }
83 }
84 }
85
86 1;