Debian Codegraph @

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