Debian Codegraph @

src/centreon/common/broadcom/megaraid/snmp/mode/components/pdrive.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 centreon::common::broadcom::megaraid::snmp::mode::components::pdrive;
22
23 use strict;
24 use warnings;
25
26 my %map_pdrive_status = (
27 0 => 'unconfigured-good', 1 => 'unconfigured-bad', 2 => 'hot-spare', 16 => 'offline',
28 17 => 'failed', 20 => 'rebuild', 24 => 'online', 32 => 'copyback', 64 => 'system', 128 => 'UNCONFIGURED-SHIELDED',
29 130 => 'HOTSPARE-SHIELDED', 144 => 'CONFIGURED-SHIELDED'
30 );
31
32 my $mapping = {
33 pdState => { oid => '.1.3.6.1.4.1.3582.4.1.4.2.1.2.1.10', map => \%map_pdrive_status },
34 pdSerialNumber => { oid => '.1.3.6.1.4.1.3582.4.1.4.2.1.2.1.37' },
35 };
36 my $oid_virtualDriveEntry = '.1.3.6.1.4.1.3582.4.1.4.2.1.2.1';
37
38 sub load {
39 my ($self) = @_;
40
41 push @{$self->{request}}, { oid => $oid_virtualDriveEntry, start => $mapping->{pdState}->{oid},
42 end => $mapping->{pdSerialNumber}->{oid} };
43 }
44
45 sub check {
46 my ($self) = @_;
47
48 $self->{output}->output_add(long_msg => "Checking physical drives");
49 $self->{components}->{pdrive} = {name => 'pdrives', total => 0, skip => 0};
50 return if ($self->check_filter(section => 'pdrive'));
51
52 my ($exit, $warn, $crit, $checked);
53 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_virtualDriveEntry}})) {
54 next if ($oid !~ /^$mapping->{pdState}->{oid}\.(.*)$/);
55 my $instance = $1;
56 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_virtualDriveEntry}, instance => $instance);
57
58 next if ($self->check_filter(section => 'pdrive', instance => $instance));
59 if ($result->{pdState} =~ /status-not-installed/i) {
60 $self->absent_problem(section => 'pdrive', instance => $instance);
61 next;
62 }
63
64 $self->{components}->{pdrive}->{total}++;
65 $self->{output}->output_add(long_msg => sprintf("Physical drive '%s' status is '%s' [instance = %s, SN = %s]",
66 $instance, $result->{pdState}, $instance, $result->{pdSerialNumber}));
67 $exit = $self->get_severity(label => 'pdrive', section => 'pdrive', value => $result->{pdState});
68 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
69 $self->{output}->output_add(severity => $exit,
70 short_msg => sprintf("Physical drive '%s' status is '%s'", $instance, $result->{pdState}));
71 }
72 }
73 }
74
75 1;