Debian Codegraph @

src/storage/emc/datadomain/snmp/mode/components/disk.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 storage::emc::datadomain::snmp::mode::components::disk;
22
23 use strict;
24 use warnings;
25 use centreon::plugins::misc;
26
27 my $oid_diskPropState;
28
29 my %map_disk_status = (
30 1 => 'ok',
31 2 => 'unknown',
32 3 => 'absent',
33 4 => 'failed',
34 5 => 'spare', # since OS 5.4
35 6 => 'available', # since OS 5.4
36 8 => 'raidReconstruction', # since OS 7.x
37 9 => 'copyReconstruction', # since OS 7.x
38 10 => 'system' # since OS 7.x
39 );
40
41 sub load {
42 my ($self) = @_;
43
44 if (centreon::plugins::misc::minimal_version($self->{os_version}, '5.x')) {
45 $oid_diskPropState = '.1.3.6.1.4.1.19746.1.6.1.1.1.8';
46 } else {
47 $oid_diskPropState = '.1.3.6.1.4.1.19746.1.6.1.1.1.7';
48 }
49 push @{$self->{request}}, { oid => $oid_diskPropState };
50 }
51
52 sub check {
53 my ($self) = @_;
54
55 $self->{output}->output_add(long_msg => "Checking disks");
56 $self->{components}->{disk} = { name => 'disks', total => 0, skip => 0 };
57 return if ($self->check_filter(section => 'disk'));
58
59 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_diskPropState}})) {
60 $oid =~ /^$oid_diskPropState\.(.*)$/;
61 my $instance = $1;
62 my $disk_status = defined($map_disk_status{$self->{results}->{$oid_diskPropState}->{$oid}}) ?
63 $map_disk_status{$self->{results}->{$oid_diskPropState}->{$oid}} : 'unknown';
64
65 next if ($self->check_filter(section => 'disk', instance => $instance));
66 next if ($disk_status =~ /absent/i &&
67 $self->absent_problem(section => 'disk', instance => $instance));
68
69 $self->{components}->{disk}->{total}++;
70 $self->{output}->output_add(
71 long_msg => sprintf(
72 "disk '%s' status is '%s'",
73 $instance, $disk_status
74 )
75 );
76
77 my $exit = $self->get_severity(section => 'disk', value => $disk_status);
78 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
79 $self->{output}->output_add(
80 severity => $exit,
81 short_msg => sprintf("Disk '%s' status is '%s'", $instance, $disk_status)
82 );
83 }
84 }
85 }
86
87 1;