Debian Codegraph @

src/hardware/server/hp/proliant/snmp/mode/components/scsipdrive.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::scsipdrive;
22
23 use strict;
24 use warnings;
25 use centreon::plugins::misc;
26
27 my %map_pdrive_status = (
28 1 => 'other',
29 2 => 'ok',
30 3 => 'failed',
31 4 => 'notConfigured',
32 5 => 'badCable',
33 6 => 'missingWasOk',
34 7 => 'missingWasFailed',
35 8 => 'predictiveFailure',
36 9 => 'missingWasPredictiveFailure',
37 10 => 'offline',
38 11 => 'missingWasOffline',
39 12 => 'hardError',
40 );
41
42 my %map_pdrive_condition = (
43 1 => 'other',
44 2 => 'ok',
45 3 => 'degraded',
46 4 => 'failed',
47 );
48
49 # In 'CPQSCSI-MIB.mib'
50
51 my $mapping = {
52 cpqScsiPhyDrvStatus => { oid => '.1.3.6.1.4.1.232.5.2.4.1.1.9', map => \%map_pdrive_status },
53 };
54 my $mapping2 = {
55 cpqScsiPhyDrvCondition => { oid => '.1.3.6.1.4.1.232.5.2.4.1.1.26', map => \%map_pdrive_condition },
56 };
57 my $oid_cpqScsiPhyDrvCondition = '.1.3.6.1.4.1.232.5.2.4.1.1.26';
58 my $oid_cpqScsiPhyDrvStatus = '.1.3.6.1.4.1.232.5.2.4.1.1.9';
59
60 sub load {
61 my ($self) = @_;
62
63 push @{$self->{request}}, { oid => $oid_cpqScsiPhyDrvStatus }, { oid => $oid_cpqScsiPhyDrvCondition };
64 }
65
66 sub check {
67 my ($self) = @_;
68
69 $self->{output}->output_add(long_msg => "Checking scsi physical drives");
70 $self->{components}->{scsipdrive} = {name => 'scsi physical drives', total => 0, skip => 0};
71 return if ($self->check_filter(section => 'scsipdrive'));
72
73 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_cpqScsiPhyDrvCondition}})) {
74 next if ($oid !~ /^$mapping->{cpqScsiPhyDrvCondition}->{oid}\.(.*)$/);
75 my $instance = $1;
76 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_cpqScsiPhyDrvStatus}, instance => $instance);
77 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$oid_cpqScsiPhyDrvCondition}, instance => $instance);
78
79 next if ($self->check_filter(section => 'scsipdrive', instance => $instance));
80 $self->{components}->{scsipdrive}->{total}++;
81
82 $self->{output}->output_add(long_msg => sprintf("scsi physical drive '%s' [status: %s] condition is %s.",
83 $instance,
84 $result->{cpqScsiPhyDrvStatus},
85 $result2->{cpqScsiPhyDrvCondition}));
86 my $exit = $self->get_severity(label => 'default', section => 'scsipdrive', value => $result2->{cpqScsiPhyDrvCondition});
87 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
88 $self->{output}->output_add(severity => $exit,
89 short_msg => sprintf("scsi physical drive '%s' is %s",
90 $instance, $result2->{cpqScsiPhyDrvCondition}));
91 }
92 }
93 }
94
95 1;