Merge pull request #2397 from centreon/fix-2395

Fix #2395
This commit is contained in:
qgarnier 2020-12-01 15:28:37 +01:00 committed by GitHub
commit 0b6de9f78f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 73 additions and 32 deletions

View File

@ -23,22 +23,22 @@ package storage::qnap::snmp::mode::components::disk;
use strict;
use warnings;
my %map_status_disk = (
my $map_status_disk = {
0 => 'ready',
'-5' => 'noDisk',
'-6' => 'invalid',
'-9' => 'rwError',
'-4' => 'unknown',
);
'-4' => 'unknown'
};
# In MIB 'NAS.mib'
my $mapping = {
HdDescr => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.2' },
HdTemperature => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.3' },
HdStatus => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.4', map => \%map_status_disk },
HdStatus => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.4', map => $map_status_disk }
};
my $mapping2 = {
HdSmartInfo => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.7' },
HdSmartInfo => { oid => '.1.3.6.1.4.1.24681.1.2.11.1.7' }
};
my $oid_HdEntry = '.1.3.6.1.4.1.24681.1.2.11.1';
@ -68,26 +68,42 @@ sub check {
$self->absent_problem(section => 'disk', instance => $instance));
$self->{components}->{disk}->{total}++;
$self->{output}->output_add(long_msg => sprintf("Disk '%s' [instance: %s, temperature: %s, smart status: %s] status is %s.",
$result->{HdDescr}, $instance, $result->{HdTemperature}, $result2->{HdSmartInfo}, $result->{HdStatus}));
$self->{output}->output_add(
long_msg => sprintf(
"Disk '%s' [instance: %s, temperature: %s, smart status: %s] status is %s.",
$result->{HdDescr}, $instance, $result->{HdTemperature}, $result2->{HdSmartInfo}, $result->{HdStatus}
)
);
my $exit = $self->get_severity(section => 'disk', value => $result->{HdStatus});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Disk '%s' status is %s.", $result->{HdDescr}, $result->{HdStatus}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Disk '%s' status is %s.", $result->{HdDescr}, $result->{HdStatus}
)
);
}
$exit = $self->get_severity(section => 'smartdisk', value => $result2->{HdSmartInfo});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Disk '%s' smart status is %s.", $result->{HdDescr}, $result2->{HdSmartInfo}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Disk '%s' smart status is %s.", $result->{HdDescr}, $result2->{HdSmartInfo}
)
);
}
if ($result->{HdTemperature} =~ /([0-9]+)\s*C/) {
my $disk_temp = $1;
my ($exit2, $warn, $crit) = $self->get_severity_numeric(section => 'disk', instance => $instance, value => $disk_temp);
if (!$self->{output}->is_status(value => $exit2, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit2,
short_msg => sprintf("Disk '%s' temperature is %s degree centigrade", $result->{HdDescr}, $disk_temp));
$self->{output}->output_add(
severity => $exit2,
short_msg => sprintf(
"Disk '%s' temperature is %s degree centigrade", $result->{HdDescr}, $disk_temp
)
);
}
$self->{output}->perfdata_add(
label => 'temp_disk', unit => 'C',

View File

@ -51,15 +51,23 @@ sub check {
next if ($self->check_filter(section => 'fan', instance => $instance));
$self->{components}->{fan}->{total}++;
$self->{output}->output_add(long_msg => sprintf("fan '%s' [instance: %s] speed is '%s'.",
$fan_descr, $instance, $fan_speed));
$self->{output}->output_add(
long_msg => sprintf(
"fan '%s' [instance: %s] speed is '%s'.",
$fan_descr, $instance, $fan_speed
)
);
if ($fan_speed =~ /([0-9]+)\s*rpm/i) {
my $fan_speed_value = $1;
my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'fan', instance => $instance, value => $fan_speed_value);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '%s' speed is %s rpm", $fan_descr, $fan_speed_value));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Fan '%s' speed is %s rpm", $fan_descr, $fan_speed_value
)
);
}
$self->{output}->perfdata_add(
label => 'fan', unit => 'rpm',

View File

@ -47,12 +47,20 @@ sub check {
my $status = $self->{results}->{$oid_raidStatus}->{$oid};
$self->{components}->{raid}->{total}++;
$self->{output}->output_add(long_msg => sprintf("raid '%s' status is %s [instance: %s]",
$instance, $status, $instance));
$self->{output}->output_add(
long_msg => sprintf(
"raid '%s' status is %s [instance: %s]",
$instance, $status, $instance
)
);
my $exit = $self->get_severity(section => 'raid', value => $status);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Raid '%s' status is %s.", $instance, $status));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"Raid '%s' status is %s.", $instance, $status
)
);
}
}
}

View File

@ -47,12 +47,20 @@ sub check {
if ($cpu_temp =~ /([0-9]+)\s*C/ && !$self->check_filter(section => 'temperature', instance => 'cpu')) {
my $value = $1;
$self->{components}->{temperature}->{total}++;
$self->{output}->output_add(long_msg => sprintf("cpu temperature is '%s' degree centigrade",
$value));
$self->{output}->output_add(
long_msg => sprintf(
"cpu temperature is '%s' degree centigrade",
$value
)
);
my ($exit, $warn, $crit) = $self->get_severity_numeric(section => 'temperature', instance => 'cpu', value => $value);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("CPU Temperature is '%s' degree centigrade", $value));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf(
"CPU Temperature is '%s' degree centigrade", $value
)
);
}
$self->{output}->perfdata_add(
label => 'temp', unit => 'C',

View File

@ -38,28 +38,29 @@ sub set_system {
['ready', 'OK'],
['invalid', 'CRITICAL'],
['rwError', 'CRITICAL'],
['unknown', 'UNKNOWN'],
['unknown', 'UNKNOWN']
],
smartdisk => [
['GOOD', 'OK'],
['NORMAL', 'OK'],
['--', 'OK'],
['.*', 'CRITICAL'],
['.*', 'CRITICAL']
],
raid => [
['Ready', 'OK'],
['Synchronizing', 'OK'],
['degraded', 'WARNING'],
['.*', 'CRITICAL'],
],
['.*', 'CRITICAL']
]
};
$self->{components_path} = 'storage::qnap::snmp::mode::components';
$self->{components_module} = ['temperature', 'disk', 'fan', 'raid'];
}
sub snmp_execute {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}