From 2c75a4de40e815ed25301ef57bf99d9012b23ca3 Mon Sep 17 00:00:00 2001 From: qgarnier Date: Wed, 28 Oct 2020 15:39:44 +0100 Subject: [PATCH] fix #1766 (#2297) --- .../mikrotik/snmp/mode/components/current.pm | 73 ++++++++---- network/mikrotik/snmp/mode/components/fan.pm | 85 +++++++------- network/mikrotik/snmp/mode/components/psu.pm | 74 +++++++++---- .../snmp/mode/components/resources.pm | 48 ++++++++ .../snmp/mode/components/temperature.pm | 104 ++++++++++-------- .../mikrotik/snmp/mode/components/voltage.pm | 71 ++++++++---- network/mikrotik/snmp/mode/environment.pm | 10 +- network/mikrotik/snmp/plugin.pm | 6 +- 8 files changed, 312 insertions(+), 159 deletions(-) create mode 100644 network/mikrotik/snmp/mode/components/resources.pm diff --git a/network/mikrotik/snmp/mode/components/current.pm b/network/mikrotik/snmp/mode/components/current.pm index eb6218649..afc210440 100644 --- a/network/mikrotik/snmp/mode/components/current.pm +++ b/network/mikrotik/snmp/mode/components/current.pm @@ -22,41 +22,72 @@ package network::mikrotik::snmp::mode::components::current; use strict; use warnings; +use network::mikrotik::snmp::mode::components::resources qw($map_gauge_unit $mapping_gauge); my $mapping = { - mtxrHlCurrent => { oid => '.1.3.6.1.4.1.14988.1.1.3.13' }, + mtxrHlCurrent => { oid => '.1.3.6.1.4.1.14988.1.1.3.13' } }; sub load {} +sub check_current { + my ($self, %options) = @_; + + $self->{output}->output_add( + long_msg => sprintf( + "current '%s' is %s A", + $options{name}, + $options{value} + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'current', instance => $options{instance}, value => $options{value}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Current '%s' is %s A", $options{name}, $options{value}) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.current.ampere', + unit => 'A', + instances => $options{name}, + value => $options{value}, + warning => $warn, + critical => $crit + ); + $self->{components}->{current}->{total}++; +} + sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking current"); - $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')); - - my $instance = 0; - my ($exit, $warn, $crit, $checked); - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); - - if (defined($result->{mtxrHlCurrent}) && $result->{mtxrHlCurrent} =~ /[0-9]+/) { - - $self->{output}->output_add(long_msg => sprintf("Current is '%s' A", $result->{mtxrHlCurrent} / 100)); - ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'current', instance => $instance, value => $result->{mtxrHlCurrent} / 100); - if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { - $self->{output}->output_add(severity => $exit, - short_msg => sprintf("Current is '%s' A", $result->{mtxrHlCurrent} / 100)); - } - $self->{output}->perfdata_add( - label => 'current', unit => 'A', - nlabel => 'hardware.current.ampere', + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0); + + if (defined($result->{mtxrHlCurrent}) && $result->{mtxrHlCurrent} =~ /[0-9]+/) { + check_current( + $self, value => $result->{mtxrHlCurrent} / 100, - warning => $warn, - critical => $crit + instance => 1, + name => 'system' + ); + } + + foreach (keys %{$self->{results}}) { + next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/); + next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dA'); + + $result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1); + check_current( + $self, + value => $result->{value} / 10, + instance => $1, + name => $result->{name} ); - $self->{components}->{current}->{total}++; } } diff --git a/network/mikrotik/snmp/mode/components/fan.pm b/network/mikrotik/snmp/mode/components/fan.pm index 77f7be728..5208b542c 100644 --- a/network/mikrotik/snmp/mode/components/fan.pm +++ b/network/mikrotik/snmp/mode/components/fan.pm @@ -22,65 +22,64 @@ package network::mikrotik::snmp::mode::components::fan; use strict; use warnings; +use network::mikrotik::snmp::mode::components::resources qw($map_gauge_unit $mapping_gauge); my $mapping = { mtxrHlFanSpeed1 => { oid => '.1.3.6.1.4.1.14988.1.1.3.17' }, - mtxrHlFanSpeed2 => { oid => '.1.3.6.1.4.1.14988.1.1.3.18' }, + mtxrHlFanSpeed2 => { oid => '.1.3.6.1.4.1.14988.1.1.3.18' } }; sub load {} +sub check_fan { + my ($self, %options) = @_; + + $self->{output}->output_add( + long_msg => sprintf( + "fan '%s' speed is '%s' RPM", + $options{instance}, + $options{value} + ) + ); + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'fan', instance => $options{instance}, value => $options{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", $options{instance}, $options{value}) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.fan.speed.rpm', + unit => 'rpm', + instances => $options{instance}, + value => $options{value}, + warning => $warn, + critical => $crit + ); + $self->{components}->{fan}->{total}++; +} + sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking fans"); - $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')); - - my $instance = 0; - my ($exit, $warn, $crit, $checked); - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); - - if (defined($result->{mtxrHlFanSpeed1}) && $result->{mtxrHlFanSpeed1} =~ /[0-9]+/) { - - $self->{output}->output_add(long_msg => sprintf("Fan '1' speed is '%s' RPM", $result->{mtxrHlFanSpeed1})); - ($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}->perfdata_add( - label => 'fan_speed', unit => 'rpm', - nlabel => 'hardware.fan.speed.rpm', - instances => '1', - value => $result->{mtxrHlFanSpeed1}, - warning => $warn, - critical => $crit - ); - $self->{components}->{fan}->{total}++; + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0); + if (defined($result->{mtxrHlFanSpeed1}) && $result->{mtxrHlFanSpeed1} =~ /[0-9]+/) { + check_fan($self, value => $result->{mtxrHlFanSpeed1}, instance => 1); } if (defined($result->{mtxrHlFanSpeed2}) && $result->{mtxrHlFanSpeed2} =~ /[0-9]+/) { - $self->{output}->output_add(long_msg => sprintf("Fan '2' speed is '%s' RPM", $result->{mtxrHlFanSpeed2})); + check_fan($self, value => $result->{mtxrHlFanSpeed2}, instance => 2); + } - ($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}->perfdata_add( - label => 'fan_speed', unit => 'rpm', - nlabel => 'hardware.fan.speed.rpm', - instances => '2', - value => $result->{mtxrHlFanSpeed2}, - warning => $warn, - critical => $crit - ); - $self->{components}->{fan}->{total}++; + foreach (keys %{$self->{results}}) { + next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/); + next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'rpm'); + + $result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1); + check_fan($self, value => $result->{value}, instance => $result->{name}); } } diff --git a/network/mikrotik/snmp/mode/components/psu.pm b/network/mikrotik/snmp/mode/components/psu.pm index 5e6c10ccc..3492c91e1 100644 --- a/network/mikrotik/snmp/mode/components/psu.pm +++ b/network/mikrotik/snmp/mode/components/psu.pm @@ -22,13 +22,14 @@ package network::mikrotik::snmp::mode::components::psu; use strict; use warnings; +use network::mikrotik::snmp::mode::components::resources qw($map_gauge_unit $mapping_gauge); my $map_status = { 0 => 'false', 1 => 'true' }; my $mapping = { 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 }, + mtxrHlBackupPowerSupplyState => { oid => '.1.3.6.1.4.1.14988.1.1.3.16', map => $map_status } }; sub load {} @@ -56,38 +57,67 @@ sub check_psu { $self->{components}->{psu}->{total}++; } +sub check_power { + my ($self, %options) = @_; + + $self->{output}->output_add( + long_msg => sprintf( + "power '%s' is %s W", + $options{name}, + $options{value} + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'psu', instance => $options{instance}, value => $options{value}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Power '%s' is %s W", $options{name}, $options{value}) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.power.watt', + unit => 'W', + instances => $options{name}, + value => $options{value}, + warning => $warn, + critical => $crit + ); + $self->{components}->{psu}->{total}++; +} + sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking power supplies"); $self->{components}->{psu} = {name => 'psu', total => 0, skip => 0}; return if ($self->check_filter(section => 'psu')); - - my $instance = '0'; - my ($exit, $warn, $crit, $checked); - my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance); + + 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'); - - if (defined($result->{mtxrHlPower}) && $result->{mtxrHlPower} =~ /[0-9]+/) { - $self->{output}->output_add(long_msg => sprintf("Power is '%s' W", $result->{mtxrHlPower} / 10)); - ($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}->perfdata_add( - label => 'power', unit => 'W', - nlabel => 'hardware.power.watt', - value => $result->{mtxrHlPower} / 10, - warning => $warn, - critical => $crit + if (defined($result->{mtxrHlPower}) && $result->{mtxrHlPower} =~ /[0-9]+/) { + check_power( + $self, + value => $result->{mtxrHlPower} / 100, + instance => 1, + name => 'system' + ); + } + + foreach (keys %{$self->{results}}) { + next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/); + next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dW'); + + $result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1); + check_power( + $self, + value => $result->{value} / 10, + instance => $1, + name => $result->{name} ); - $self->{components}->{psu}->{total}++; } } diff --git a/network/mikrotik/snmp/mode/components/resources.pm b/network/mikrotik/snmp/mode/components/resources.pm new file mode 100644 index 000000000..169e92905 --- /dev/null +++ b/network/mikrotik/snmp/mode/components/resources.pm @@ -0,0 +1,48 @@ +# +# 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::resources; + +use strict; +use warnings; +use Exporter; + +our $map_gauge_unit; +our $mapping_gauge; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw($map_gauge_unit $mapping_gauge); + +$mapping_gauge = { + name => { oid => '.1.3.6.1.4.1.14988.1.1.3.100.1.2' }, # mtxrGaugeName + value => { oid => '.1.3.6.1.4.1.14988.1.1.3.100.1.3' }, # mtxrGaugeName + unit => { oid => '.1.3.6.1.4.1.14988.1.1.3.100.1.4' } # mtxrGaugeUnit +}; + +$map_gauge_unit = { + 1 => 'celsius', + 2 => 'rpm', + 3 => 'dV', + 4 => 'dA', + 5 => 'dW', + 6 => 'status' +}; + +1; diff --git a/network/mikrotik/snmp/mode/components/temperature.pm b/network/mikrotik/snmp/mode/components/temperature.pm index 1b8b6abe2..9ca9232f4 100644 --- a/network/mikrotik/snmp/mode/components/temperature.pm +++ b/network/mikrotik/snmp/mode/components/temperature.pm @@ -22,14 +22,47 @@ package network::mikrotik::snmp::mode::components::temperature; use strict; use warnings; +use network::mikrotik::snmp::mode::components::resources qw($map_gauge_unit $mapping_gauge); my $mapping = { mtxrHlTemperature => { oid => '.1.3.6.1.4.1.14988.1.1.3.10' }, # SoC or PCB according to Mikrotik support - mtxrHlProcessorTemperature => { oid => '.1.3.6.1.4.1.14988.1.1.3.11' }, + mtxrHlProcessorTemperature => { oid => '.1.3.6.1.4.1.14988.1.1.3.11' } }; sub load {} +sub check_temperature { + my ($self, %options) = @_; + + $self->{output}->output_add( + long_msg => sprintf( + "%s is %s C", + $options{description}, + $options{value} + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'temperature', instance => $options{instance}, value => $options{value}); + if ($options{value} == -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("%s is %s C", $options{instance}, $options{value}) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.temperature.celsius', + unit => 'C', + instances => $options{name}, + value => $options{value}, + warning => $warn, + critical => $crit + ); + $self->{components}->{temperature}->{total}++; +} + sub check { my ($self) = @_; @@ -37,56 +70,39 @@ sub check { $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)); + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0); - ($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 (!$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}->perfdata_add( - label => 'temperature', unit => 'C', - nlabel => 'hardware.temperature.celsius', - instances => 'system', + if (defined($result->{mtxrHlTemperature}) && $result->{mtxrHlTemperature} =~ /[0-9]+/) { + check_temperature( + $self, value => $result->{mtxrHlTemperature} / 10, - warning => $warn, - critical => $crit + instance => 1, + name => 'system', + description => 'system temperature (SoC or PCB)' ); - $self->{components}->{temperature}->{total}++; } if (defined($result->{mtxrHlProcessorTemperature}) && $result->{mtxrHlProcessorTemperature} =~ /[0-9]+/) { - - $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 (!$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}->perfdata_add( - label => 'temperature', unit => 'C', - nlabel => 'hardware.temperature.celsius', - instances => 'processor', + check_temperature( + $self, value => $result->{mtxrHlProcessorTemperature} / 10, - warning => $warn, - critical => $crit + instance => 2, + name => 'processor', + description => 'processor temperature' + ); + } + + foreach (keys %{$self->{results}}) { + next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/); + next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'celsius'); + + $result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1); + check_temperature( + $self, + value => $result->{value}, + instance => $1, + name => $result->{name}, + description => "sensor temperature '$result->{name}'" ); - $self->{components}->{temperature}->{total}++; } } diff --git a/network/mikrotik/snmp/mode/components/voltage.pm b/network/mikrotik/snmp/mode/components/voltage.pm index 87e8acc60..e52db218b 100644 --- a/network/mikrotik/snmp/mode/components/voltage.pm +++ b/network/mikrotik/snmp/mode/components/voltage.pm @@ -22,42 +22,71 @@ package network::mikrotik::snmp::mode::components::voltage; use strict; use warnings; +use network::mikrotik::snmp::mode::components::resources qw($map_gauge_unit $mapping_gauge); my $mapping = { - mtxrHlVoltage => { oid => '.1.3.6.1.4.1.14988.1.1.3.8' }, + mtxrHlVoltage => { oid => '.1.3.6.1.4.1.14988.1.1.3.8' } }; sub load {} +sub check_voltage { + my ($self, %options) = @_; + + $self->{output}->output_add( + long_msg => sprintf( + "voltage '%s' is %s V", + $options{name}, + $options{value} + ) + ); + + my ($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'voltage', instance => $options{instance}, value => $options{value}); + if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { + $self->{output}->output_add( + severity => $exit, + short_msg => sprintf("Voltage '%s' is %s V", $options{name}, $options{value}) + ); + } + $self->{output}->perfdata_add( + nlabel => 'hardware.voltage.volt', + unit => 'V', + instances => $options{name}, + value => $options{value}, + warning => $warn, + critical => $crit + ); + $self->{components}->{voltage}->{total}++; +} + sub check { my ($self) = @_; $self->{output}->output_add(long_msg => "Checking voltage"); $self->{components}->{voltage} = {name => 'voltage', total => 0, skip => 0}; return if ($self->check_filter(section => 'voltage')); - - my $instance = 0; - my ($exit, $warn, $crit, $checked); - 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}->perfdata_add( - label => 'voltage', unit => 'V', - nlabel => 'hardware.voltage.volt', + my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0); + if (defined($result->{mtxrHlVoltage}) && $result->{mtxrHlVoltage} =~ /[0-9]+/) { + check_voltage( + $self, value => $result->{mtxrHlVoltage} / 10, - warning => $warn, - critical => $crit + instance => 1, + name => 'system' + ); + } + + foreach (keys %{$self->{results}}) { + next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/); + next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dV'); + + $result = $self->{snmp}->map_instance(mapping => $mapping_gauge, results => $self->{results}, instance => $1); + check_voltage( + $self, + value => $result->{value} / 10, + instance => $1, + name => $result->{name} ); - $self->{components}->{voltage}->{total}++; } } diff --git a/network/mikrotik/snmp/mode/environment.pm b/network/mikrotik/snmp/mode/environment.pm index df61e0bf1..643bfe7a2 100644 --- a/network/mikrotik/snmp/mode/environment.pm +++ b/network/mikrotik/snmp/mode/environment.pm @@ -28,18 +28,18 @@ use warnings; sub set_system { my ($self, %options) = @_; - $self->{regexp_threshold_numeric_check_section_option} = '^(temperature|voltage|fan|current|psu)$'; + $self->{regexp_threshold_numeric_check_section_option} = '^(?:temperature|voltage|fan|current|psu)$'; $self->{cb_hook2} = 'snmp_execute'; $self->{thresholds} = { 'psu.primary' => [ ['true', 'OK'], - ['false', 'CRITICAL'], + ['false', 'CRITICAL'] ], 'psu.backup' => [ ['true', 'OK'], - ['false', 'CRITICAL'], - ], + ['false', 'CRITICAL'] + ] }; $self->{components_path} = 'network::mikrotik::snmp::mode::components'; @@ -56,7 +56,7 @@ sub snmp_execute { sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; $options{options}->add_options(arguments => { diff --git a/network/mikrotik/snmp/plugin.pm b/network/mikrotik/snmp/plugin.pm index d79b3eb55..0e964f458 100644 --- a/network/mikrotik/snmp/plugin.pm +++ b/network/mikrotik/snmp/plugin.pm @@ -30,7 +30,7 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - %{$self->{modes}} = ( + $self->{modes} = { 'cpu' => 'snmp_standard::mode::cpu', 'disk' => 'network::mikrotik::snmp::mode::disk', 'environment' => 'network::mikrotik::snmp::mode::environment', @@ -41,8 +41,8 @@ sub new { 'memory' => 'network::mikrotik::snmp::mode::memory', 'signal' => 'network::mikrotik::snmp::mode::signal', 'time' => 'snmp_standard::mode::ntp', - 'uptime' => 'snmp_standard::mode::uptime', - ); + 'uptime' => 'snmp_standard::mode::uptime' + }; return $self; }