Debian Codegraph @

src/hardware/server/dell/openmanage/snmp/mode/components/logicaldrive.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::logicaldrive;
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 15 => 'resynching',
34 24 => 'rebuild',
35 26 => 'formatting',
36 35 => 'initializing',
37 );
38 my %map_layout = (
39 1 => 'Concatened',
40 2 => 'RAID-0',
41 3 => 'RAID-1',
42 4 => 'RAID-2',
43 5 => 'RAID-3',
44 6 => 'RAID-4',
45 7 => 'RAID-5',
46 8 => 'RAID-6',
47 9 => 'RAID-7',
48 10 => 'RAID-10',
49 11 => 'RAID-30',
50 12 => 'RAID-50',
51 13 => 'Add spares',
52 14 => 'Delete logical',
53 15 => 'Transform logical',
54 18 => 'RAID-0-plus-1 - Mylex only',
55 19 => 'Concatened RAID 1',
56 20 => 'Concatened RAID 5',
57 21 => 'no RAID',
58 22 => 'RAID Morph - Adapted only',
59 );
60 my %map_status = (
61 1 => 'other',
62 2 => 'unknown',
63 3 => 'ok',
64 4 => 'nonCritical',
65 5 => 'critical',
66 6 => 'nonRecoverable',
67 );
68
69 # In MIB 'dcstorag.mib'
70 my $mapping = {
71 virtualDiskName => { oid => '.1.3.6.1.4.1.674.10893.1.20.140.1.1.2' },
72 virtualDiskDeviceName => { oid => '.1.3.6.1.4.1.674.10893.1.20.140.1.1.3' },
73 virtualDiskState => { oid => '.1.3.6.1.4.1.674.10893.1.20.140.1.1.4', map => \%map_state },
74 };
75 my $mapping2 = {
76 virtualDiskLengthInMB => { oid => '.1.3.6.1.4.1.674.10893.1.20.140.1.1.6' },
77 };
78 my $mapping3 = {
79 virtualDiskLayout => { oid => '.1.3.6.1.4.1.674.10893.1.20.140.1.1.13', map => \%map_layout },
80 };
81 my $mapping4 = {
82 virtualDiskComponentStatus => { oid => '.1.3.6.1.4.1.674.10893.1.20.140.1.1.20', map => \%map_status },
83 };
84 my $oid_virtualDiskEntry = '.1.3.6.1.4.1.674.10893.1.20.140.1.1';
85
86 sub load {
87 my ($self) = @_;
88
89 push @{$self->{request}}, { oid => $oid_virtualDiskEntry, start => $mapping->{virtualDiskName}->{oid}, end => $mapping->{virtualDiskState}->{oid} },
90 { oid => $mapping2->{virtualDiskLengthInMB}->{oid} }, { oid => $mapping3->{virtualDiskLayout}->{oid} }, { oid => $mapping4->{virtualDiskComponentStatus}->{oid} };
91 }
92
93 sub check {
94 my ($self) = @_;
95
96 $self->{output}->output_add(long_msg => "Checking logical drives");
97 $self->{components}->{logicaldrive} = {name => 'logical drives', total => 0, skip => 0};
98 return if ($self->check_filter(section => 'logicaldrive'));
99
100 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping4->{virtualDiskComponentStatus}->{oid}}})) {
101 next if ($oid !~ /^$mapping4->{virtualDiskComponentStatus}->{oid}\.(.*)$/);
102 my $instance = $1;
103 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_virtualDiskEntry}, instance => $instance);
104 my $result2 = $self->{snmp}->map_instance(mapping => $mapping2, results => $self->{results}->{$mapping2->{virtualDiskLengthInMB}->{oid}}, instance => $instance);
105 my $result3 = $self->{snmp}->map_instance(mapping => $mapping3, results => $self->{results}->{$mapping3->{virtualDiskLayout}->{oid}}, instance => $instance);
106 my $result4 = $self->{snmp}->map_instance(mapping => $mapping4, results => $self->{results}->{$mapping4->{virtualDiskComponentStatus}->{oid}}, instance => $instance);
107
108 next if ($self->check_filter(section => 'logicaldrive', instance => $instance));
109
110 $self->{components}->{logicaldrive}->{total}++;
111
112 $self->{output}->output_add(long_msg => sprintf("Logical drive '%s' status is '%s' [instance: %s, size: %s MB, layout: %s, state: %s, device name: %s]",
113 $result->{virtualDiskName}, $result4->{virtualDiskComponentStatus}, $instance,
114 $result2->{virtualDiskLengthInMB}, $result3->{virtualDiskLayout},
115 $result->{virtualDiskState}, $result->{virtualDiskDeviceName}
116 ));
117 my $exit = $self->get_severity(label => 'default', section => 'logicaldrive', value => $result4->{virtualDiskComponentStatus});
118 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
119 $self->{output}->output_add(severity => $exit,
120 short_msg => sprintf("Logical drive '%s' status is '%s'",
121 $result->{virtualDiskName}, $result4->{virtualDiskComponentStatus}));
122 }
123 }
124 }
125
126 1;