enh(Mikrotik) various enhancements (#2319)
This commit is contained in:
parent
98a6113a3e
commit
582996cbcb
|
@ -41,7 +41,7 @@ sub check_current {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'current', instance => $options{instance}, value => $options{value});
|
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'current', instance => $options{name}, value => $options{value});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(
|
$self->{output}->output_add(
|
||||||
severity => $exit,
|
severity => $exit,
|
||||||
|
@ -66,28 +66,23 @@ sub check {
|
||||||
$self->{components}->{current} = { name => 'current', total => 0, skip => 0 };
|
$self->{components}->{current} = { name => 'current', total => 0, skip => 0 };
|
||||||
return if ($self->check_filter(section => 'current'));
|
return if ($self->check_filter(section => 'current'));
|
||||||
|
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
|
|
||||||
|
|
||||||
my $gauge_ok = 0;
|
|
||||||
foreach (keys %{$self->{results}}) {
|
foreach (keys %{$self->{results}}) {
|
||||||
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
|
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
|
||||||
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dA');
|
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dA');
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1);
|
||||||
$result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1);
|
next if ($self->check_filter(section => 'current', instance => $result->{name}));
|
||||||
check_current(
|
check_current(
|
||||||
$self,
|
$self,
|
||||||
value => $result->{value} / 10,
|
value => $result->{value} / 10,
|
||||||
instance => $1,
|
|
||||||
name => $result->{name}
|
name => $result->{name}
|
||||||
);
|
);
|
||||||
$gauge_ok = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($gauge_ok == 0 && defined($result->{mtxrHlCurrent}) && $result->{mtxrHlCurrent} =~ /[0-9]+/) {
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
|
||||||
|
if (defined($result->{mtxrHlCurrent}) && ! $self->check_filter(section => 'current', instance => 'system')) {
|
||||||
check_current(
|
check_current(
|
||||||
$self,
|
$self,
|
||||||
value => $result->{mtxrHlCurrent} / 1000,
|
value => $result->{mtxrHlCurrent} / 1000,
|
||||||
instance => 1,
|
|
||||||
name => 'system'
|
name => 'system'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,22 +36,23 @@ sub check_fan {
|
||||||
|
|
||||||
$self->{output}->output_add(
|
$self->{output}->output_add(
|
||||||
long_msg => sprintf(
|
long_msg => sprintf(
|
||||||
"fan '%s' speed is '%s' RPM",
|
"fan '%s' is %s RPM",
|
||||||
$options{instance},
|
$options{name},
|
||||||
$options{value}
|
$options{value}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $options{instance}, value => $options{value});
|
|
||||||
|
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $options{name}, value => $options{value});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(
|
$self->{output}->output_add(
|
||||||
severity => $exit,
|
severity => $exit,
|
||||||
short_msg => sprintf("Fan '%s' speed is '%s' RPM", $options{instance}, $options{value})
|
short_msg => sprintf("Fan '%s' is %s RPM", $options{name}, $options{value})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
nlabel => 'hardware.fan.speed.rpm',
|
nlabel => 'hardware.fan.speed.rpm',
|
||||||
unit => 'rpm',
|
unit => 'rpm',
|
||||||
instances => $options{instance},
|
instances => $options{name},
|
||||||
value => $options{value},
|
value => $options{value},
|
||||||
warning => $warn,
|
warning => $warn,
|
||||||
critical => $crit
|
critical => $crit
|
||||||
|
@ -62,27 +63,36 @@ sub check_fan {
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Checking fans");
|
$self->{output}->output_add(long_msg => "Checking fan");
|
||||||
$self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 };
|
$self->{components}->{fan} = { name => 'fans', total => 0, skip => 0 };
|
||||||
return if ($self->check_filter(section => 'fan'));
|
return if ($self->check_filter(section => 'fan'));
|
||||||
|
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
|
|
||||||
|
|
||||||
my $gauge_ok = 0;
|
|
||||||
foreach (keys %{$self->{results}}) {
|
foreach (keys %{$self->{results}}) {
|
||||||
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
|
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
|
||||||
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'rpm');
|
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'rpm');
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1);
|
||||||
$result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1);
|
next if ($self->check_filter(section => 'fan', instance => $result->{name}));
|
||||||
check_fan($self, value => $result->{value}, instance => $result->{name});
|
check_fan(
|
||||||
$gauge_ok = 1;
|
$self,
|
||||||
|
value => $result->{value},
|
||||||
|
name => $result->{name}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($gauge_ok == 0 && defined($result->{mtxrHlFanSpeed1}) && $result->{mtxrHlFanSpeed1} =~ /[0-9]+/) {
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
|
||||||
check_fan($self, value => $result->{mtxrHlFanSpeed1}, instance => 1);
|
if (defined($result->{mtxrHlFanSpeed1}) && ! $self->check_filter(section => 'fan', instance => 'fan1')) {
|
||||||
|
check_fan(
|
||||||
|
$self,
|
||||||
|
value => $result->{mtxrHlFanSpeed1},
|
||||||
|
name => 'fan1'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if ($gauge_ok == 0 && defined($result->{mtxrHlFanSpeed2}) && $result->{mtxrHlFanSpeed2} =~ /[0-9]+/) {
|
if (defined($result->{mtxrHlFanSpeed2}) && ! $self->check_filter(section => 'fan', instance => 'fan2')) {
|
||||||
check_fan($self, value => $result->{mtxrHlFanSpeed2}, instance => 2);
|
check_fan(
|
||||||
|
$self,
|
||||||
|
value => $result->{mtxrHlFanSpeed2},
|
||||||
|
name => 'fan2'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,45 +18,19 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
package network::mikrotik::snmp::mode::components::psu;
|
package network::mikrotik::snmp::mode::components::power;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use network::mikrotik::snmp::mode::components::resources qw($map_gauge_unit $mapping_gauge);
|
use network::mikrotik::snmp::mode::components::resources qw($map_gauge_unit $mapping_gauge);
|
||||||
|
|
||||||
my $map_status = { 0 => 'false', 1 => 'true' };
|
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
mtxrHlPower => { oid => '.1.3.6.1.4.1.14988.1.1.3.12' },
|
mtxrHlPower => { oid => '.1.3.6.1.4.1.14988.1.1.3.12' }
|
||||||
mtxrHlPowerSupplyState => { oid => '.1.3.6.1.4.1.14988.1.1.3.15', map => $map_status },
|
|
||||||
mtxrHlBackupPowerSupplyState => { oid => '.1.3.6.1.4.1.14988.1.1.3.16', map => $map_status }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
sub load {}
|
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'",
|
|
||||||
$options{type}, $options{value},
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
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->{components}->{psu}->{total}++;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub check_power {
|
sub check_power {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
@ -68,7 +42,7 @@ sub check_power {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'psu', instance => $options{instance}, value => $options{value});
|
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'power', instance => $options{name}, value => $options{value});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(
|
$self->{output}->output_add(
|
||||||
severity => $exit,
|
severity => $exit,
|
||||||
|
@ -83,41 +57,33 @@ sub check_power {
|
||||||
warning => $warn,
|
warning => $warn,
|
||||||
critical => $crit
|
critical => $crit
|
||||||
);
|
);
|
||||||
$self->{components}->{psu}->{total}++;
|
$self->{components}->{power}->{total}++;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check {
|
sub check {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "Checking power supplies");
|
$self->{output}->output_add(long_msg => "Checking power");
|
||||||
$self->{components}->{psu} = {name => 'psu', total => 0, skip => 0};
|
$self->{components}->{power} = {name => 'power', total => 0, skip => 0};
|
||||||
return if ($self->check_filter(section => 'psu'));
|
return if ($self->check_filter(section => 'power'));
|
||||||
|
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
|
|
||||||
|
|
||||||
check_psu($self, value => $result->{mtxrHlPowerSupplyState}, type => 'primary');
|
|
||||||
check_psu($self, value => $result->{mtxrHlBackupPowerSupplyState}, type => 'backup');
|
|
||||||
|
|
||||||
my $gauge_ok = 0;
|
|
||||||
foreach (keys %{$self->{results}}) {
|
foreach (keys %{$self->{results}}) {
|
||||||
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
|
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
|
||||||
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dW');
|
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dW');
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1);
|
||||||
$result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1);
|
next if ($self->check_filter(section => 'power', instance => $result->{name}));
|
||||||
check_power(
|
check_power(
|
||||||
$self,
|
$self,
|
||||||
value => $result->{value} / 10,
|
value => $result->{value} / 10,
|
||||||
instance => $1,
|
|
||||||
name => $result->{name}
|
name => $result->{name}
|
||||||
);
|
);
|
||||||
$gauge_ok = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($gauge_ok == 0 && defined($result->{mtxrHlPower}) && $result->{mtxrHlPower} =~ /[0-9]+/) {
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
|
||||||
|
if (defined($result->{mtxrHlpower}) && ! $self->check_filter(section => 'power', instance => 'system')) {
|
||||||
check_power(
|
check_power(
|
||||||
$self,
|
$self,
|
||||||
value => $result->{mtxrHlPower} / 10,
|
value => $result->{mtxrHlpower} / 10,
|
||||||
instance => 1,
|
|
||||||
name => 'system'
|
name => 'system'
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -0,0 +1,91 @@
|
||||||
|
#
|
||||||
|
# Copyright 2020 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package network::mikrotik::snmp::mode::components::status;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use network::mikrotik::snmp::mode::components::resources qw($map_gauge_unit $mapping_gauge);
|
||||||
|
|
||||||
|
my $mapping = {
|
||||||
|
mtxrHlPowerSupplyState => { oid => '.1.3.6.1.4.1.14988.1.1.3.15' },
|
||||||
|
mtxrHlBackupPowerSupplyState => { oid => '.1.3.6.1.4.1.14988.1.1.3.16' }
|
||||||
|
};
|
||||||
|
|
||||||
|
sub load {}
|
||||||
|
|
||||||
|
sub check_status {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{output}->output_add(
|
||||||
|
long_msg => sprintf(
|
||||||
|
"status '%s' is %s",
|
||||||
|
$options{name},
|
||||||
|
$options{value}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
my $exit = $self->get_severity(section => 'status', value => $options{value});
|
||||||
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
|
$self->{output}->output_add(
|
||||||
|
severity => $exit,
|
||||||
|
short_msg => sprintf("Status '%s' is %s", $options{name}, $options{value})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$self->{components}->{status}->{total}++;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
$self->{output}->output_add(long_msg => "Checking status");
|
||||||
|
$self->{components}->{status} = {name => 'status', total => 0, skip => 0};
|
||||||
|
return if ($self->check_filter(section => 'status'));
|
||||||
|
|
||||||
|
foreach (keys %{$self->{results}}) {
|
||||||
|
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
|
||||||
|
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'status');
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1);
|
||||||
|
next if ($self->check_filter(section => 'status', instance => $result->{name}));
|
||||||
|
check_status(
|
||||||
|
$self,
|
||||||
|
value => $result->{value} == 0 ? 'ok' : 'not ok',
|
||||||
|
name => $result->{name}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
|
||||||
|
if (defined($result->{mtxrHlPowerSupplyState}) && ! $self->check_filter(section => 'status', instance => 'psu-primary')) {
|
||||||
|
check_status(
|
||||||
|
$self,
|
||||||
|
value => $result->{mtxrHlPowerSupplyState} == 1 ? 'ok' : 'not ok',
|
||||||
|
name => 'psu-primary'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (defined($result->{mtxrHlBackupPowerSupplyState}) && ! $self->check_filter(section => 'status', instance => 'psu-backup')) {
|
||||||
|
check_status(
|
||||||
|
$self,
|
||||||
|
value => $result->{mtxrHlBackupPowerSupplyState} == 1 ? 'ok' : 'not ok',
|
||||||
|
name => 'psu-backup'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
|
@ -36,20 +36,20 @@ sub check_temperature {
|
||||||
|
|
||||||
$self->{output}->output_add(
|
$self->{output}->output_add(
|
||||||
long_msg => sprintf(
|
long_msg => sprintf(
|
||||||
"%s is %s C",
|
"temperature '%s' is %s C",
|
||||||
$options{description},
|
$options{name},
|
||||||
$options{value}
|
$options{value}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $options{instance}, value => $options{value});
|
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $options{name}, value => $options{value});
|
||||||
if ($options{value} == -2730) { # RouterOS returns this when the SNMP agent hangs...
|
if ($options{value} == -273) { # RouterOS returns this when the SNMP agent hangs...
|
||||||
$exit = 'UNKNOWN';
|
$exit = 'UNKNOWN';
|
||||||
}
|
}
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(
|
$self->{output}->output_add(
|
||||||
severity => $exit,
|
severity => $exit,
|
||||||
short_msg => sprintf("%s is %s C", $options{instance}, $options{value})
|
short_msg => sprintf("Temperature '%s' is %s C", $options{name}, $options{value})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
|
@ -70,40 +70,31 @@ sub check {
|
||||||
$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'));
|
return if ($self->check_filter(section => 'temperature'));
|
||||||
|
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
|
|
||||||
|
|
||||||
my $gauge_ok = 0;
|
|
||||||
foreach (keys %{$self->{results}}) {
|
foreach (keys %{$self->{results}}) {
|
||||||
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
|
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
|
||||||
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'celsius');
|
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'celsius');
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1);
|
||||||
$result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1);
|
next if ($self->check_filter(section => 'temperature', instance => $result->{name}));
|
||||||
check_temperature(
|
check_temperature(
|
||||||
$self,
|
$self,
|
||||||
value => $result->{value},
|
value => $result->{value},
|
||||||
instance => $1,
|
name => $result->{name}
|
||||||
name => $result->{name},
|
|
||||||
description => "sensor temperature '$result->{name}'"
|
|
||||||
);
|
);
|
||||||
$gauge_ok = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($gauge_ok == 0 && defined($result->{mtxrHlTemperature}) && $result->{mtxrHlTemperature} =~ /[0-9]+/) {
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
|
||||||
|
if (defined($result->{mtxrHlTemperature}) && ! $self->check_filter(section => 'temperature', instance => 'system')) {
|
||||||
check_temperature(
|
check_temperature(
|
||||||
$self,
|
$self,
|
||||||
value => $result->{mtxrHlTemperature} / 10,
|
value => $result->{mtxrHlTemperature} / 10,
|
||||||
instance => 1,
|
name => 'system'
|
||||||
name => 'system',
|
|
||||||
description => 'system temperature (SoC or PCB)'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($gauge_ok == 0 && defined($result->{mtxrHlProcessorTemperature}) && $result->{mtxrHlProcessorTemperature} =~ /[0-9]+/) {
|
if (defined($result->{mtxrHlProcessorTemperature}) && ! $self->check_filter(section => 'temperature', instance => 'processor')) {
|
||||||
check_temperature(
|
check_temperature(
|
||||||
$self,
|
$self,
|
||||||
value => $result->{mtxrHlProcessorTemperature} / 10,
|
value => $result->{mtxrHlProcessorTemperature} / 10,
|
||||||
instance => 2,
|
name => 'processor'
|
||||||
name => 'processor',
|
|
||||||
description => 'processor temperature'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ sub check_voltage {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $options{instance}, value => $options{value});
|
my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $options{name}, value => $options{value});
|
||||||
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
$self->{output}->output_add(
|
$self->{output}->output_add(
|
||||||
severity => $exit,
|
severity => $exit,
|
||||||
|
@ -66,28 +66,23 @@ sub check {
|
||||||
$self->{components}->{voltage} = {name => 'voltage', total => 0, skip => 0};
|
$self->{components}->{voltage} = {name => 'voltage', total => 0, skip => 0};
|
||||||
return if ($self->check_filter(section => 'voltage'));
|
return if ($self->check_filter(section => 'voltage'));
|
||||||
|
|
||||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
|
|
||||||
|
|
||||||
my $gauge_ok = 0;
|
|
||||||
foreach (keys %{$self->{results}}) {
|
foreach (keys %{$self->{results}}) {
|
||||||
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
|
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
|
||||||
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dV');
|
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dV');
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1);
|
||||||
$result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1);
|
next if ($self->check_filter(section => 'voltage', instance => $result->{name}));
|
||||||
check_voltage(
|
check_voltage(
|
||||||
$self,
|
$self,
|
||||||
value => $result->{value} / 10,
|
value => $result->{value} / 10,
|
||||||
instance => $1,
|
|
||||||
name => $result->{name}
|
name => $result->{name}
|
||||||
);
|
);
|
||||||
$gauge_ok = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($gauge_ok == 0 && defined($result->{mtxrHlVoltage}) && $result->{mtxrHlVoltage} =~ /[0-9]+/) {
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
|
||||||
|
if (defined($result->{mtxrHlVoltage}) && ! $self->check_filter(section => 'voltage', instance => 'system')) {
|
||||||
check_voltage(
|
check_voltage(
|
||||||
$self,
|
$self,
|
||||||
value => $result->{mtxrHlVoltage} / 10,
|
value => $result->{mtxrHlVoltage} / 10,
|
||||||
instance => 1,
|
|
||||||
name => 'system'
|
name => 'system'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,28 +28,27 @@ use warnings;
|
||||||
sub set_system {
|
sub set_system {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature|voltage|fan|current|psu)$';
|
$self->{regexp_threshold_numeric_check_section_option} = '^(?:current|fan|power|temperature|voltage)$';
|
||||||
|
|
||||||
$self->{cb_hook2} = 'snmp_execute';
|
$self->{cb_hook2} = 'snmp_execute';
|
||||||
$self->{thresholds} = {
|
$self->{thresholds} = {
|
||||||
'psu.primary' => [
|
'status' => [
|
||||||
['true', 'OK'],
|
['not ok', 'CRITICAL'],
|
||||||
['false', 'CRITICAL']
|
['ok', 'OK']
|
||||||
],
|
|
||||||
'psu.backup' => [
|
|
||||||
['true', 'OK'],
|
|
||||||
['false', 'CRITICAL']
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
$self->{components_path} = 'network::mikrotik::snmp::mode::components';
|
$self->{components_path} = 'network::mikrotik::snmp::mode::components';
|
||||||
$self->{components_module} = ['current', 'fan', 'psu', 'temperature', 'voltage'];
|
$self->{components_module} = ['current', 'fan', 'power', 'status', 'temperature', 'voltage'];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub snmp_execute {
|
sub snmp_execute {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
|
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3.100.1';
|
||||||
|
if (defined($self->{option_results}->{legacy})) {
|
||||||
|
$oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
|
||||||
|
}
|
||||||
$self->{snmp} = $options{snmp};
|
$self->{snmp} = $options{snmp};
|
||||||
$self->{results} = $self->{snmp}->get_table(oid => $oid_mtxrHealth);
|
$self->{results} = $self->{snmp}->get_table(oid => $oid_mtxrHealth);
|
||||||
}
|
}
|
||||||
|
@ -60,6 +59,7 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
|
'legacy' => { name => 'legacy' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -75,15 +75,19 @@ Check hardware.
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
=item B<--legacy>
|
||||||
|
|
||||||
|
Look for legacy (prior to RouterOS 6.47) OIDs.
|
||||||
|
|
||||||
=item B<--component>
|
=item B<--component>
|
||||||
|
|
||||||
Which component to check (Default: '.*').
|
Which component to check (Default: '.*').
|
||||||
Can be: 'current', 'fan', 'psu', 'temperature', 'voltage'.
|
Can be: 'current', 'fan', 'power', 'status', 'temperature', 'voltage'.
|
||||||
|
|
||||||
=item B<--filter>
|
=item B<--filter>
|
||||||
|
|
||||||
Exclude some parts (comma seperated list) (Example: --filter=fan --filter=voltage)
|
Exclude some parts (comma seperated list) (Example: --filter=fan --filter=voltage)
|
||||||
Can also exclude specific instance: --filter=fan,1.1
|
Can also exclude specific instance: --filter=fan,fan2
|
||||||
|
|
||||||
=item B<--no-component>
|
=item B<--no-component>
|
||||||
|
|
||||||
|
@ -98,7 +102,7 @@ Example: --warning='temperature,.*,40'
|
||||||
=item B<--critical>
|
=item B<--critical>
|
||||||
|
|
||||||
Set critical threshold for 'temperature', 'fan', 'voltage' (syntax: type,regexp,threshold)
|
Set critical threshold for 'temperature', 'fan', 'voltage' (syntax: type,regexp,threshold)
|
||||||
Example: --critical='temperature,.*,50'
|
Example: --critical='temperature,cpu,50'
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue