| 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::disk; |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
|
| 28 |
my $mapping = { |
| 29 |
v6 => { |
| 30 |
diskState => { oid => '.1.3.6.1.4.1.4526.22.3.1.9' }, |
| 31 |
diskTemperature => { oid => '.1.3.6.1.4.1.4526.22.3.1.10' } |
| 32 |
}, |
| 33 |
v4 => { |
| 34 |
diskState => { oid => '.1.3.6.1.4.1.4526.18.3.1.4' }, |
| 35 |
diskTemperature => { oid => '.1.3.6.1.4.1.4526.18.3.1.5' } |
| 36 |
} |
| 37 |
}; |
| 38 |
my $oid_diskTable = { |
| 39 |
v4 => '.1.3.6.1.4.1.4526.18.3', |
| 40 |
v6 => '.1.3.6.1.4.1.4526.22.3' |
| 41 |
}; |
| 42 |
|
| 43 |
sub load { |
| 44 |
my ($self) = @_; |
| 45 |
|
| 46 |
push @{$self->{request}}, { |
| 47 |
oid => $oid_diskTable->{$self->{mib_ver}}, |
| 48 |
start => $mapping->{$self->{mib_ver}}->{diskState}->{oid}, |
| 49 |
end => $mapping->{$self->{mib_ver}}->{diskTemperature}->{oid} |
| 50 |
}; |
| 51 |
} |
| 52 |
|
| 53 |
sub check { |
| 54 |
my ($self) = @_; |
| 55 |
|
| 56 |
$self->{output}->output_add(long_msg => "checking disks"); |
| 57 |
$self->{components}->{disk} = {name => 'disk', total => 0, skip => 0}; |
| 58 |
return if ($self->check_filter(section => 'disk')); |
| 59 |
|
| 60 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %{$self->{results}->{ $oid_diskTable->{$self->{mib_ver}} }})) { |
| 61 |
next if ($oid !~ /^$mapping->{$self->{mib_ver}}->{diskState}->{oid}\.(\d+)/); |
| 62 |
my $instance = $1; |
| 63 |
my $result = $self->{snmp}->map_instance(mapping => $mapping->{$self->{mib_ver}}, results => $self->{results}->{ $oid_diskTable->{$self->{mib_ver}} }, instance => $instance); |
| 64 |
|
| 65 |
next if ($self->check_filter(section => 'disk', instance => $instance)); |
| 66 |
$self->{components}->{disk}->{total}++; |
| 67 |
|
| 68 |
my $temperature_value = defined($result->{diskTemperature}) && $result->{diskTemperature} != -1 ? $result->{diskTemperature} : '-'; |
| 69 |
my $temperature_unit = $self->{mib_ver} eq 'v6' ? 'C' : 'F'; |
| 70 |
|
| 71 |
$self->{output}->output_add( |
| 72 |
long_msg => sprintf( |
| 73 |
"disk '%s' status is %s [temperature: %s%s]", |
| 74 |
$instance, $result->{diskState}, $temperature_value, $temperature_unit |
| 75 |
) |
| 76 |
); |
| 77 |
|
| 78 |
my $exit = $self->get_severity(section => 'disk', value => $result->{diskState}); |
| 79 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 80 |
$self->{output}->output_add( |
| 81 |
severity => $exit, |
| 82 |
short_msg => sprintf("Disk '%s' status is %s", $instance, $result->{diskState}) |
| 83 |
); |
| 84 |
} |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
1; |