Debian Codegraph @

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