Debian Codegraph @

src/hardware/server/hp/proliant/snmp/mode/components/daldrive.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::daldrive;
22
23 use strict;
24 use warnings;
25
26 my %map_daldrive_condition = (
27 1 => 'other',
28 2 => 'ok',
29 3 => 'degraded',
30 4 => 'failed',
31 );
32 my %map_ldrive_status = (
33 1 => 'other',
34 2 => 'ok',
35 3 => 'failed',
36 4 => 'unconfigured',
37 5 => 'recovering',
38 6 => 'readyForRebuild',
39 7 => 'rebuilding',
40 8 => 'wrongDrive',
41 9 => 'badConnect',
42 10 => 'overheating',
43 11 => 'shutdown',
44 12 => 'expanding',
45 13 => 'notAvailable',
46 14 => 'queuedForExpansion',
47 15 => 'multipathAccessDegraded',
48 16 => 'erasing',
49 );
50 my %map_faulttol = (
51 1 => 'other',
52 2 => 'none',
53 3 => 'mirroring',
54 4 => 'dataGuard',
55 5 => 'distribDataGuard',
56 7 => 'advancedDataGuard',
57 8 => 'raid50',
58 9 => 'raid60',
59 );
60 # In 'CPQIDA-MIB.mib'
61 my $mapping = {
62 cpqDaLogDrvFaultTol => { oid => '.1.3.6.1.4.1.232.3.2.3.1.1.3', map => \%map_faulttol },
63 cpqDaLogDrvStatus => { oid => '.1.3.6.1.4.1.232.3.2.3.1.1.4', map => \%map_ldrive_status },
64 };
65 my $mapping2 = {
66 cpqDaLogDrvCondition => { oid => '.1.3.6.1.4.1.232.3.2.3.1.1.11', map => \%map_daldrive_condition },
67 };
68 my $oid_cpqDaLogDrvEntry = '.1.3.6.1.4.1.232.3.2.3.1.1';
69 my $oid_cpqDaLogDrvCondition = '.1.3.6.1.4.1.232.3.2.3.1.1.11';
70
71 sub load {
72 my ($self) = @_;
73
74 push @{$self->{request}}, { oid => $oid_cpqDaLogDrvEntry, start => $mapping->{cpqDaLogDrvFaultTol}->{oid}, end => $mapping->{cpqDaLogDrvStatus}->{oid} },
75 { oid => $oid_cpqDaLogDrvCondition };
76 }
77
78 sub check {
79 my ($self) = @_;
80
81 $self->{output}->output_add(long_msg => "Checking da logical drives");
82 $self->{components}->{daldrive} = {name => 'da logical drives', total => 0, skip => 0};
83 return if ($self->check_filter(section => 'daldrive'));
84
85 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpqDaLogDrvCondition}})) {
86 next if ($oid !~ /^$mapping2->{cpqDaLogDrvCondition}->{oid}\.(.*)$/);
87 my $instance = $1;
88 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpqDaLogDrvEntry}, instance => $instance);
89 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cpqDaLogDrvCondition}, instance => $instance);
90
91 next if ($self->check_filter(section => 'daldrive', instance => $instance));
92 $self->{components}->{daldrive}->{total}++;
93
94 $self->{output}->output_add(long_msg => sprintf("da logical drive '%s' [fault tolerance: %s, condition: %s] status is %s.",
95 $instance,
96 $result->{cpqDaLogDrvFaultTol},
97 $result2->{cpqDaLogDrvCondition},
98 $result->{cpqDaLogDrvStatus}));
99 my $exit = $self->get_severity(section => 'daldrive', value => $result->{cpqDaLogDrvStatus});
100 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
101 $self->{output}->output_add(severity => $exit,
102 short_msg => sprintf("da logical drive '%s' is %s",
103 $instance, $result->{cpqDaLogDrvStatus}));
104 }
105 }
106 }
107
108 1;