Debian Codegraph @

src/storage/synology/snmp/mode/components/system.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::system;
22
23 use strict;
24 use warnings;
25
26 my $map_status = { 1 => 'Normal', 2 => 'Failed' };
27
28 my $mapping = {
29 synoSystemsystemStatus => { oid => '.1.3.6.1.4.1.6574.1.1', map => $map_status }
30 };
31
32 # Synology support note :
33 # OID .1.3.6.1.4.1.6574.1.1 should change integer to 2 when the partition is fully crashed
34 # (i.e. md0 or md1 status in /proc/mdstat is [E___] or similar),
35 # not when it is degraded (health status is [U_U_], [U_____], or [UUUU_]).
36
37 sub load {
38 my ($self) = @_;
39
40 push @{$self->{request_leef}}, $mapping->{synoSystemsystemStatus}->{oid} . '.0';
41 }
42
43 sub check {
44 my ($self) = @_;
45
46 $self->{output}->output_add(long_msg => "Checking system partition status");
47 $self->{components}->{system} = {name => 'system', total => 0, skip => 0};
48 return if ($self->check_filter(section => 'system'));
49
50 my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results_leef}, instance => '0');
51 return if (!defined($result->{synoSystemsystemStatus}));
52
53 $self->{components}->{system}->{total}++;
54
55 $self->{output}->output_add(
56 long_msg => sprintf(
57 "system partition status is %s.",
58 $result->{synoSystemsystemStatus}
59 )
60 );
61 my $exit = $self->get_severity(label => 'default', section => 'system', value => $result->{synoSystemsystemStatus});
62 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
63 $self->{output}->output_add(
64 severity => $exit,
65 short_msg => sprintf("System partition status is %s.", $result->{synoSystemsystemStatus})
66 );
67 }
68 }
69
70 1;