Debian Codegraph @

src/centreon/common/adic/tape/snmp/mode/components/physicaldrive.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::adic::tape::snmp::mode::components::physicaldrive;
22
23 use strict;
24 use warnings;
25 use centreon::plugins::misc;
26
27 my %map_status = (
28 1 => 'good',
29 2 => 'failed',
30 3 => 'degraded',
31 4 => 'warning',
32 5 => 'informational',
33 6 => 'unknown',
34 7 => 'invalid',
35 );
36
37 my $mapping = {
38 # 'ADIC-TAPE-LIBRARY-MIB'
39 adic_tape => {
40 phDriveSerialNumber => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.2' },
41 phDriveModel => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.3' },
42 phDriveRasStatus => { oid => '.1.3.6.1.4.1.3764.1.10.10.11.3.1.11', map => \%map_status },
43 },
44 # 'ADIC-MANAGEMENT-MIB'
45 adic_management => {
46 phDriveSerialNumber => { oid => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1.8' },
47 phDriveModel => { oid => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1.7' }, # phDriveProduct
48 phDriveRasStatus => { oid => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1.31', map => \%map_status },
49 }
50 };
51
52 my %oid_table = (
53 adic_tape => '.1.3.6.1.4.1.3764.1.10.10.11.3.1', # physicalDriveEntry
54 adic_management => '.1.3.6.1.4.1.3764.1.1.200.20.80.110.1', # phDriveEntry
55 );
56
57 sub load {
58 my ($self) = @_;
59
60 push @{$self->{request}}, { oid => $oid_table{adic_tape} }, { oid => $oid_table{adic_management} };
61 }
62
63 sub check {
64 my ($self) = @_;
65
66 $self->{output}->output_add(long_msg => "Checking physical drives");
67 $self->{components}->{physicaldrive} = {name => 'physical drives', total => 0, skip => 0};
68 return if ($self->check_filter(section => 'physicaldrive'));
69
70 foreach my $label (keys %{$mapping}) {
71 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_table{$label}}})) {
72 next if ($oid !~ /^$mapping->{$label}->{phDriveRasStatus}->{oid}\.(.*)$/);
73 my $instance = $1;
74 my $result = $self->{snmp}->map_instance(mapping => $mapping->{$label}, results => $self->{results}->{$oid_table{$label}}, instance => $instance);
75
76 $result->{phDriveSerialNumber} = centreon::plugins::misc::trim($result->{phDriveSerialNumber});
77
78 next if ($self->check_filter(section => 'physicaldrive', instance => $result->{phDriveSerialNumber}));
79 $self->{components}->{physicaldrive}->{total}++;
80
81 $self->{output}->output_add(long_msg => sprintf("physical drive '%s' status is %s [instance: %s, model: %s, serial: %s].",
82 $result->{phDriveSerialNumber}, $result->{phDriveRasStatus},
83 $result->{phDriveSerialNumber}, centreon::plugins::misc::trim($result->{phDriveModel}),
84 centreon::plugins::misc::trim($result->{phDriveSerialNumber})
85 ));
86 my $exit = $self->get_severity(section => 'physicaldrive', label => 'default', value => $result->{phDriveRasStatus});
87 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
88 $self->{output}->output_add(severity => $exit,
89 short_msg => sprintf("Physical drive '%s' status is %s",
90 $result->{phDriveSerialNumber}, $result->{phDriveRasStatus}));
91 }
92 }
93 }
94 }
95
96 1;