Debian Codegraph @

src/storage/netgear/readynas/snmp/mode/components/volume.pm

raw
1 #
2 # Copyright 2018 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 # Author : ArnoMLT
21 #
22
23 package storage::netgear::readynas::snmp::mode::components::volume;
24
25 use strict;
26 use warnings;
27
28 my $mapping = {
29 v6 => {
30 volumeName => { oid => '.1.3.6.1.4.1.4526.22.7.1.2' },
31 volumeStatus => { oid => '.1.3.6.1.4.1.4526.22.7.1.4' }
32 },
33 v4 => {
34 volumeName => { oid => '.1.3.6.1.4.1.4526.18.7.1.2' },
35 volumeStatus => { oid => '.1.3.6.1.4.1.4526.18.7.1.4' }
36 }
37 };
38 my $oid_volumeTable = {
39 v4 => '.1.3.6.1.4.1.4526.18.7',
40 v6 => '.1.3.6.1.4.1.4526.22.7'
41 };
42
43 sub load {
44 my ($self) = @_;
45
46 push @{$self->{request}}, {
47 oid => $oid_volumeTable->{$self->{mib_ver}},
48 start => $mapping->{$self->{mib_ver}}->{volumeName}->{oid},
49 end => $mapping->{$self->{mib_ver}}->{volumeStatus}->{oid}
50 };
51 }
52
53 sub check {
54 my ($self) = @_;
55
56 $self->{output}->output_add(long_msg => "checking volume");
57 $self->{components}->{volume} = {name => 'volume', total => 0, skip => 0};
58 return if ($self->check_filter(section => 'volume'));
59
60 foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $oid_volumeTable->{$self->{mib_ver}} }})) {
61 next if ($oid !~ /^$mapping->{$self->{mib_ver}}->{volumeStatus}->{oid}\.(\d+)/);
62 my $instance = $1;
63 my $result = $self->{snmp}->map_instance(mapping => $mapping->{$self->{mib_ver}}, results => $self->{results}->{ $oid_volumeTable->{$self->{mib_ver}} }, instance => $instance);
64
65 next if ($self->check_filter(section => 'volume', instance => $instance));
66 $self->{components}->{volume}->{total}++;
67
68 $self->{output}->output_add(long_msg => sprintf("volume '%s' status is %s [instance: %s]",
69 $result->{volumeName}, $result->{volumeStatus}, $instance));
70 my $exit = $self->get_severity(section => 'volume', value => $result->{volumeStatus});
71 if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
72 $self->{output}->output_add(severity => $exit,
73 short_msg => sprintf("Volume '%s' status is %s",
74 $result->{volumeName}, $result->{volumeStatus}));
75 }
76 }
77 }
78
79 1;