Debian Codegraph @

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