This commit is contained in:
garnier-quentin 2020-02-13 14:56:45 +01:00
parent a6960f356e
commit 43585bb0dc
4 changed files with 38 additions and 27 deletions

View File

@ -47,8 +47,10 @@ sub check {
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => '1', value => $result->{mtxrHlFanSpeed1});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '1' speed is '%s' RPM", $result->{mtxrHlFanSpeed1}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Fan '1' speed is '%s' RPM", $result->{mtxrHlFanSpeed1})
);
}
$self->{output}->perfdata_add(
label => 'fan_speed', unit => 'rpm',
@ -61,13 +63,14 @@ sub check {
$self->{components}->{fan}->{total}++;
}
if (defined($result->{mtxrHlFanSpeed2}) && $result->{mtxrHlFanSpeed2} =~ /[0-9]+/) {
$self->{output}->output_add(long_msg => sprintf("Fan '2' speed is '%s' RPM", $result->{mtxrHlFanSpeed2}));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => '2', value => $result->{mtxrHlFanSpeed2});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Fan '2' speed is '%s' RPM", $result->{mtxrHlFanSpeed2}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Fan '2' speed is '%s' RPM", $result->{mtxrHlFanSpeed2})
);
}
$self->{output}->perfdata_add(
label => 'fan_speed', unit => 'rpm',

View File

@ -35,9 +35,9 @@ sub load {}
sub check_psu {
my ($self, %options) = @_;
return if (!defined($options{value}));
$self->{output}->output_add(
long_msg => sprintf(
"psu %s status is '%s'",
@ -47,8 +47,10 @@ sub check_psu {
my $exit = $self->get_severity(section => 'psu.' . $options{type}, value => $options{value});
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("psu %s status is '%s'", $options{type}, $options{value}));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("psu %s status is '%s'", $options{type}, $options{value})
);
}
$self->{components}->{psu}->{total}++;
@ -73,8 +75,10 @@ sub check {
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'psu', instance => $instance, value => $result->{mtxrHlPower} / 10);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Power is '%s' W", $result->{mtxrHlPower} / 10));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Power is '%s' W", $result->{mtxrHlPower} / 10)
);
}
$self->{output}->perfdata_add(
label => 'power', unit => 'W',

View File

@ -34,24 +34,25 @@ sub check {
my ($self) = @_;
$self->{output}->output_add(long_msg => "Checking temperature");
$self->{components}->{temperature} = {name => 'temperature', total => 0, skip => 0};
$self->{components}->{temperature} = { name => 'temperature', total => 0, skip => 0 };
return if ($self->check_filter(section => 'temperature'));
my $instance = 0;
my ($exit, $warn, $crit, $checked);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
if (defined($result->{mtxrHlTemperature}) && $result->{mtxrHlTemperature} =~ /[0-9]+/) {
$self->{output}->output_add(long_msg => sprintf("System temperature (SoC or PCB) is '%s' C", $result->{mtxrHlTemperature} / 10));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => '1', value => $result->{mtxrHlTemperature} / 10);
if ($result->{mtxrHlTemperature} == -2730) { # RouterOS returns this when the SNMP agent hangs...
$exit = 'UNKNOWN';
}
if ($result->{mtxrHlTemperature} == -2730) { # RouterOS returns this when the SNMP agent hangs...
$exit = 'UNKNOWN';
}
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("System temperature (SoC or PCB) is '%s' C", $result->{mtxrHlTemperature} / 10));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("System temperature (SoC or PCB) is '%s' C", $result->{mtxrHlTemperature} / 10)
);
}
$self->{output}->perfdata_add(
label => 'temperature', unit => 'C',
@ -68,12 +69,14 @@ sub check {
$self->{output}->output_add(long_msg => sprintf("Processor temperature is '%s' C", $result->{mtxrHlProcessorTemperature} / 10));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => '2', value => $result->{mtxrHlProcessorTemperature} / 10);
if ($result->{mtxrHlProcessorTemperature} == -2730) { # RouterOS returns this when the SNMP agent hangs...
$exit = 'UNKNOWN';
}
if ($result->{mtxrHlProcessorTemperature} == -2730) { # RouterOS returns this when the SNMP agent hangs...
$exit = 'UNKNOWN';
}
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Processor temperature is '%s' C", $result->{mtxrHlProcessorTemperature} / 10));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Processor temperature is '%s' C", $result->{mtxrHlProcessorTemperature} / 10)
);
}
$self->{output}->perfdata_add(
label => 'temperature', unit => 'C',

View File

@ -41,13 +41,14 @@ sub check {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
if (defined($result->{mtxrHlVoltage}) && $result->{mtxrHlVoltage} =~ /[0-9]+/) {
$self->{output}->output_add(long_msg => sprintf("Voltage is '%s' V", $result->{mtxrHlVoltage} / 10));
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $instance, value => $result->{mtxrHlVoltage} / 10);
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Voltage is '%s' V", $result->{mtxrHlVoltage} / 10));
$self->{output}->output_add(
severity => $exit,
short_msg => sprintf("Voltage is '%s' V", $result->{mtxrHlVoltage} / 10)
);
}
$self->{output}->perfdata_add(
label => 'voltage', unit => 'V',