Debian Codegraph @

src/storage/synology/snmp/mode/components/raid.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::synology::snmp::mode::components::raid;
22
23 use strict;
24 use warnings;
25
26 my $map_raid_status = {
27 1 => 'Normal',
28 2 => 'Repairing',
29 3 => 'Migrating',
30 4 => 'Expanding',
31 5 => 'Deleting',
32 6 => 'Creating',
33 7 => 'RaidSyncing',
34 8 => 'RaidParityChecking',
35 9 => 'RaidAssembling',
36 10 => 'Canceling',
37 11 => 'Degrade',
38 12 => 'Crashed',
39 13 => 'DataScrubbing',
40 14 => 'RaidDeploying',
41 15 => 'RaidUnDeploying',
42 16 => 'RaidMountCache',
43 17 => 'RaidUnmountCache',
44 18 => 'RaidExpandingUnfinishedSHR',
45 19 => 'RaidConvertSHRToPool',
46 20 => 'RaidMigrateSHR1ToSHR2',
47 21 => 'RaidUnknownStatus'
48 };
49
50 my $mapping = {
51 synoRaidraidName => { oid => '.1.3.6.1.4.1.6574.3.1.1.2' },
52 synoRaidraidStatus => { oid => '.1.3.6.1.4.1.6574.3.1.1.3', map => $map_raid_status }
53 };
54 my $oid_synoRaid = '.1.3.6.1.4.1.6574.3.1.1';
55
56 sub load {
57 my ($self) = @_;
58
59 push @{$self->{request}}, {
60 oid => $oid_synoRaid,
61 start => $mapping->{synoRaidraidName}->{oid},
62 end => $mapping->{synoRaidraidStatus}->{oid}
63 };
64 }
65
66 sub check {
67 my ($self) = @_;
68
69 $self->{output}->output_add(long_msg => "Checking raid");
70 $self->{components}->{raid} = {name => 'raid', total => 0, skip => 0};
71 return if ($self->check_filter(section => 'raid'));
72
73 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_synoRaid}})) {
74 next if ($oid !~ /^$mapping->{synoRaidraidStatus}->{oid}\.(\d+)/);
75 my $instance = $1;
76 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_synoRaid}, instance => $instance);
77
78 next if ($self->check_filter(section => 'raid', instance => $instance));
79 $self->{components}->{raid}->{total}++;
80
81 $self->{output}->output_add(
82 long_msg => sprintf(
83 "raid '%s' status is %s [instance: %s]",
84 $result->{synoRaidraidName}, $result->{synoRaidraidStatus}, $instance
85 )
86 );
87
88 my $exit = $self->get_severity(section => 'raid', value => $result->{synoRaidraidStatus});
89 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
90 $self->{output}->output_add(
91 severity => $exit,
92 short_msg => sprintf(
93 "Raid '%s' status is %s",
94 $result->{synoRaidraidName}, $result->{synoRaidraidStatus}
95 )
96 );
97 }
98 }
99 }
100
101 1;