Debian Codegraph @

src/hardware/server/dell/openmanage/snmp/mode/components/physicaldisk.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::dell::openmanage::snmp::mode::components::physicaldisk;
22
23 use strict;
24 use warnings;
25
26 my %map_state = (
27 0 => 'unknown',
28 1 => 'ready',
29 2 => 'failed',
30 3 => 'online',
31 4 => 'offline',
32 6 => 'degraded',
33 7 => 'recovering',
34 11 => 'removed',
35 15 => 'resynching',
36 24 => 'rebuild',
37 25 => 'noMedia',
38 26 => 'formatting',
39 28 => 'diagnostics',
40 35 => 'initializing',
41 );
42 my %map_spareState = (
43 1 => 'memberVD',
44 2 => 'memberDG',
45 3 => 'globalHostSpare',
46 4 => 'dedicatedHostSpare',
47 5 => 'notASpare',
48 );
49 my %map_status = (
50 1 => 'other',
51 2 => 'unknown',
52 3 => 'ok',
53 4 => 'nonCritical',
54 5 => 'critical',
55 6 => 'nonRecoverable',
56 );
57 my %map_smartAlertIndication = (
58 1 => 'no',
59 2 => 'yes',
60 );
61
62 # In MIB 'dcstorag.mib'
63 my $mapping = {
64 arrayDiskName => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.4.1.2' },
65 };
66 my $mapping2 = {
67 arrayDiskState => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.4.1.4', map => \%map_state },
68 };
69 my $mapping3 = {
70 arrayDiskSpareState => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.4.1.22', map => \%map_spareState },
71 };
72 my $mapping4 = {
73 arrayDiskComponentStatus => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.4.1.24', map => \%map_status },
74 };
75 my $mapping5 = {
76 arrayDiskSmartAlertIndication => { oid => '.1.3.6.1.4.1.674.10893.1.20.130.4.1.31', map => \%map_smartAlertIndication },
77 };
78
79 sub load {
80 my ($self) = @_;
81
82 push @{$self->{request}}, { oid => $mapping->{arrayDiskName}->{oid} }, { oid => $mapping2->{arrayDiskState}->{oid} },
83 { oid => $mapping3->{arrayDiskSpareState}->{oid} }, { oid => $mapping4->{arrayDiskComponentStatus}->{oid} },
84 { oid => $mapping5->{arrayDiskSmartAlertIndication}->{oid} };
85 }
86
87
88 sub check {
89 my ($self) = @_;
90
91 $self->{output}->output_add(long_msg => "Checking physical disks");
92 $self->{components}->{physicaldisk} = {name => 'physical disks', total => 0, skip => 0};
93 return if ($self->check_filter(section => 'physicaldisk'));
94
95 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping4->{arrayDiskComponentStatus}->{oid}}})) {
96 next if ($oid !~ /^$mapping4->{arrayDiskComponentStatus}->{oid}\.(.*)$/);
97 my $instance = $1;
98 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{arrayDiskName}->{oid}}, instance => $instance);
99 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{arrayDiskState}->{oid}}, instance => $instance);
100 my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{arrayDiskSpareState}->{oid}}, instance => $instance);
101 my $result4 = $self->{snmp}->map_instance(mapping => $mapping4, results => $self->{results}->{$mapping4->{arrayDiskComponentStatus}->{oid}}, instance => $instance);
102 my $result5 = $self->{snmp}->map_instance(mapping => $mapping5, results => $self->{results}->{$mapping5->{arrayDiskSmartAlertIndication}->{oid}}, instance => $instance);
103
104 next if ($self->check_filter(section => 'physicaldisk', instance => $instance));
105
106 $self->{components}->{physicaldisk}->{total}++;
107
108 $self->{output}->output_add(long_msg => sprintf("Physical Disk '%s' status is '%s' [instance: %s, state: %s, spare state: %s, smart alert: %s]",
109 $result->{arrayDiskName}, $result4->{arrayDiskComponentStatus}, $instance,
110 $result2->{arrayDiskState}, $result3->{arrayDiskSpareState},
111 defined($result5->{arrayDiskSmartAlertIndication}) ? $result5->{arrayDiskSmartAlertIndication} : '-'
112 ));
113 my $exit = $self->get_severity(label => 'default', section => 'physicaldisk', value => $result4->{arrayDiskComponentStatus});
114 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
115 $self->{output}->output_add(severity => $exit,
116 short_msg => sprintf("Physical Disk '%s' status is '%s'",
117 $result->{arrayDiskName}, $result4->{arrayDiskComponentStatus}));
118 }
119
120 if (defined($result5->{arrayDiskSmartAlertIndication})) {
121 $exit = $self->get_severity(section => 'physicaldisk_smartalert', value => $result5->{arrayDiskSmartAlertIndication});
122 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
123 $self->{output}->output_add(severity => $exit,
124 short_msg => sprintf("physical disk '%s' has received a predictive failure alert",
125 $result->{arrayDiskName}));
126 }
127 }
128 }
129 }
130
131 1;