| 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::qnap::snmp::mode::components::mdisk; |
| 22 |
|
| 23 |
use strict; |
| 24 |
use warnings; |
| 25 |
|
| 26 |
my $map_smartinfo = { |
| 27 |
2 => 'abnormal', |
| 28 |
1 => 'warning', |
| 29 |
0 => 'good', |
| 30 |
-1 => 'error' |
| 31 |
}; |
| 32 |
|
| 33 |
my $mapping = { |
| 34 |
ex => { |
| 35 |
description => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.6.2.1.2' }, # msatadiskID |
| 36 |
status => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.6.2.1.4' }, # msatadiskSummary |
| 37 |
smartinfo => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.6.2.1.5', map => $map_smartinfo }, # msatadiskSmartInfo |
| 38 |
temperature => { oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.6.2.1.6' } # msatadiskTemperature |
| 39 |
} |
| 40 |
}; |
| 41 |
|
| 42 |
sub load {} |
| 43 |
|
| 44 |
sub check_mdisk_ex { |
| 45 |
my ($self) = @_; |
| 46 |
|
| 47 |
my $snmp_result = $self->{snmp}->get_table( |
| 48 |
oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.6.2', # msataDiskTable |
| 49 |
start => $mapping->{ex}->{description}->{oid}, |
| 50 |
end => $mapping->{ex}->{temperature}->{oid} |
| 51 |
); |
| 52 |
foreach my $oid ($self->{snmp}->oid_lex_sort(keys %$snmp_result)) { |
| 53 |
next if ($oid !~ /^$mapping->{ex}->{description}->{oid}\.(\d+)$/); |
| 54 |
my $instance = $1; |
| 55 |
|
| 56 |
my $result = $self->{snmp}->map_instance(mapping => $mapping->{ex}, results => $snmp_result, instance => $instance); |
| 57 |
|
| 58 |
next if ($self->check_filter(section => 'mdisk', instance => $instance)); |
| 59 |
|
| 60 |
$self->{components}->{mdisk}->{total}++; |
| 61 |
$self->{output}->output_add( |
| 62 |
long_msg => sprintf( |
| 63 |
"mDisk '%s' status is %s [instance: %s, temperature: %s, smart status: %s]", |
| 64 |
$result->{description}, |
| 65 |
$result->{status}, |
| 66 |
$instance, |
| 67 |
$result->{temperature}, |
| 68 |
$result->{smartinfo} |
| 69 |
) |
| 70 |
); |
| 71 |
my $exit = $self->get_severity(label => 'disk', section => 'mdisk', instance => $instance, value => $result->{status}); |
| 72 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 73 |
$self->{output}->output_add( |
| 74 |
severity => $exit, |
| 75 |
short_msg => sprintf( |
| 76 |
"mDisk '%s' status is %s.", $result->{description}, $result->{status} |
| 77 |
) |
| 78 |
); |
| 79 |
} |
| 80 |
|
| 81 |
$exit = $self->get_severity(section => 'smartdisk', value => $result->{smartinfo}); |
| 82 |
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { |
| 83 |
$self->{output}->output_add( |
| 84 |
severity => $exit, |
| 85 |
short_msg => sprintf( |
| 86 |
"mDisk '%s' smart status is %s.", $result->{description}, $result->{smartinfo} |
| 87 |
) |
| 88 |
); |
| 89 |
} |
| 90 |
|
| 91 |
next if ($result->{temperature} !~ /([0-9]+)/); |
| 92 |
|
| 93 |
my $disk_temp = $1; |
| 94 |
my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'mdisk', instance => $instance, value => $disk_temp); |
| 95 |
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) { |
| 96 |
$self->{output}->output_add( |
| 97 |
severity => $exit2, |
| 98 |
short_msg => sprintf( |
| 99 |
"mDisk '%s' temperature is %s degree centigrade", $result->{description}, $disk_temp |
| 100 |
) |
| 101 |
); |
| 102 |
} |
| 103 |
$self->{output}->perfdata_add( |
| 104 |
nlabel => 'hardware.mdisk.temperature.celsius', |
| 105 |
unit => 'C', |
| 106 |
instances => $instance, |
| 107 |
value => $disk_temp |
| 108 |
); |
| 109 |
} |
| 110 |
} |
| 111 |
|
| 112 |
sub check { |
| 113 |
my ($self) = @_; |
| 114 |
|
| 115 |
$self->{output}->output_add(long_msg => 'Checking mdisks'); |
| 116 |
$self->{components}->{mdisk} = { name => 'mdisks', total => 0, skip => 0 }; |
| 117 |
return if ($self->check_filter(section => 'mdisk')); |
| 118 |
|
| 119 |
if ($self->{is_es} == 0) { |
| 120 |
check_mdisk_ex($self); |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
1; |