Debian Codegraph @

src/hardware/server/dell/idrac/snmp/mode/components/pdisk.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::idrac::snmp::mode::components::pdisk;
22
23 use strict;
24 use warnings;
25 use hardware::server::dell::idrac::snmp::mode::components::resources qw(%map_status %map_pdisk_state %map_pdisk_smartstate);
26
27 my $map_pdisk_sparestate = {
28 1 => '', # notASpare
29 2 => 'SpareDedicated', # dedicatedHotSpare
30 3 => 'SpareGlobal' # globalHotSpare
31 };
32
33 my $mapping = {
34 physicalDiskState => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.4', map => \%map_pdisk_state },
35 physicalDiskSpareState => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.22', map => $map_pdisk_sparestate },
36 physicalDiskComponentStatus => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.24', map => \%map_status },
37 physicalDiskSmartAlertIndication => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.31', map => \%map_pdisk_smartstate },
38 physicalDiskFQDD => { oid => '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1.54' }
39 };
40 my $oid_physicalDiskTableEntry = '.1.3.6.1.4.1.674.10892.5.5.1.20.130.4.1';
41
42 sub load {
43 my ($self) = @_;
44
45 foreach (keys %$mapping) {
46 push @{$self->{request}}, { oid => $mapping->{$_}->{oid} };
47 }
48 }
49
50 sub check {
51 my ($self) = @_;
52
53 $self->{output}->output_add(long_msg => "Checking physical disks");
54 $self->{components}->{pdisk} = {name => 'physical disks', total => 0, skip => 0};
55 return if ($self->check_filter(section => 'pdisk'));
56
57 my $results = {};
58 foreach (keys %{$mapping}) {
59 $results = { %$results, %{$self->{results}->{$mapping->{$_}->{oid}}} }
60 }
61
62 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$mapping->{physicalDiskComponentStatus}->{oid}}})) {
63 $oid =~ /^$mapping->{physicalDiskComponentStatus}->{oid}\.(.*)$/;
64 my $instance = $1;
65 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
66
67 next if ($self->check_filter(section => 'pdisk', instance => $instance, name => $result->{physicalDiskFQDD}));
68 $self->{components}->{pdisk}->{total}++;
69
70 if ($result->{physicalDiskState} eq 'ready') {
71 $result->{physicalDiskState} .= $result->{physicalDiskSpareState};
72 }
73
74 $self->{output}->output_add(
75 long_msg => sprintf(
76 "physical disk '%s' status is '%s' [instance: %s] [state: %s] [smart alert: %s]",
77 $result->{physicalDiskFQDD}, $result->{physicalDiskComponentStatus}, $instance,
78 $result->{physicalDiskState}, $result->{physicalDiskSmartAlertIndication}
79 )
80 );
81
82 my $exit = $self->get_severity(section => 'pdisk.state', value => $result->{physicalDiskState});
83 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
84 $self->{output}->output_add(
85 severity => $exit,
86 short_msg => sprintf("physical disk '%s' state is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskState})
87 );
88 next;
89 }
90
91 $exit = $self->get_severity(label => 'default.status', section => 'pdisk.status', value => $result->{physicalDiskComponentStatus});
92 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
93 $self->{output}->output_add(
94 severity => $exit,
95 short_msg => sprintf("physical disk '%s' status is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskComponentStatus})
96 );
97 }
98
99 $exit = $self->get_severity(section => 'pdisk.smartalert', value => $result->{physicalDiskSmartAlertIndication});
100 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
101 $self->{output}->output_add(
102 severity => $exit,
103 short_msg => sprintf("physical disk '%s' smart alert predictive failure is '%s'", $result->{physicalDiskFQDD}, $result->{physicalDiskSmartAlertIndication})
104 );
105 }
106 }
107 }
108
109 1;