Fix #1440
This commit is contained in:
parent
8073d8de4b
commit
34571d6914
|
@ -27,13 +27,7 @@ my $mapping = {
|
|||
mtxrHlCurrent => { oid => '.1.3.6.1.4.1.14988.1.1.3.13' },
|
||||
};
|
||||
|
||||
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_mtxrHealth };
|
||||
}
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
@ -44,7 +38,7 @@ sub check {
|
|||
|
||||
my $instance = 0;
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_mtxrHealth}, instance => $instance);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
|
||||
|
||||
if (defined($result->{mtxrHlCurrent}) && $result->{mtxrHlCurrent} =~ /[0-9]+/) {
|
||||
|
||||
|
|
|
@ -28,13 +28,7 @@ my $mapping = {
|
|||
mtxrHlFanSpeed2 => { oid => '.1.3.6.1.4.1.14988.1.1.3.18' },
|
||||
};
|
||||
|
||||
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_mtxrHealth };
|
||||
}
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
@ -45,7 +39,7 @@ sub check {
|
|||
|
||||
my $instance = 0;
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_mtxrHealth}, instance => $instance);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
|
||||
|
||||
if (defined($result->{mtxrHlFanSpeed1}) && $result->{mtxrHlFanSpeed1} =~ /[0-9]+/) {
|
||||
|
||||
|
|
|
@ -18,39 +18,60 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package network::mikrotik::snmp::mode::components::power;
|
||||
package network::mikrotik::snmp::mode::components::psu;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $map_status = { 0 => 'false', 1 => 'true' };
|
||||
|
||||
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 },
|
||||
};
|
||||
|
||||
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
|
||||
sub load {}
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
sub check_psu {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_mtxrHealth };
|
||||
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 {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->output_add(long_msg => "Checking power");
|
||||
$self->{components}->{power} = {name => 'power', total => 0, skip => 0};
|
||||
return if ($self->check_filter(section => 'power'));
|
||||
$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 $instance = '0';
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_mtxrHealth}, instance => $instance);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
|
||||
|
||||
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}));
|
||||
|
||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'power', instance => $instance, value => $result->{mtxrHlPower});
|
||||
($exit, $warn, $crit, $checked) = $self->get_severity_numeric(section => 'psu', instance => $instance, value => $result->{mtxrHlPower});
|
||||
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}));
|
||||
|
@ -59,7 +80,7 @@ sub check {
|
|||
value => $result->{mtxrHlPower},
|
||||
warning => $warn,
|
||||
critical => $crit);
|
||||
$self->{components}->{power}->{total}++;
|
||||
$self->{components}->{psu}->{total}++;
|
||||
}
|
||||
}
|
||||
|
|
@ -28,13 +28,7 @@ my $mapping = {
|
|||
mtxrHlProcessorTemperature => { oid => '.1.3.6.1.4.1.14988.1.1.3.11' },
|
||||
};
|
||||
|
||||
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_mtxrHealth };
|
||||
}
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
@ -45,7 +39,7 @@ sub check {
|
|||
|
||||
my $instance = 0;
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_mtxrHealth}, instance => $instance);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
|
||||
|
||||
if (defined($result->{mtxrHlTemperature}) && $result->{mtxrHlTemperature} =~ /[0-9]+/) {
|
||||
|
||||
|
|
|
@ -27,13 +27,7 @@ my $mapping = {
|
|||
mtxrHlVoltage => { oid => '.1.3.6.1.4.1.14988.1.1.3.8' },
|
||||
};
|
||||
|
||||
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
|
||||
|
||||
sub load {
|
||||
my ($self) = @_;
|
||||
|
||||
push @{$self->{request}}, { oid => $oid_mtxrHealth };
|
||||
}
|
||||
sub load {}
|
||||
|
||||
sub check {
|
||||
my ($self) = @_;
|
||||
|
@ -44,7 +38,7 @@ sub check {
|
|||
|
||||
my $instance = 0;
|
||||
my ($exit, $warn, $crit, $checked);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_mtxrHealth}, instance => $instance);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
|
||||
|
||||
if (defined($result->{mtxrHlVoltage}) && $result->{mtxrHlVoltage} =~ /[0-9]+/) {
|
||||
|
||||
|
|
|
@ -28,19 +28,30 @@ use warnings;
|
|||
sub set_system {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{regexp_threshold_numeric_check_section_option} = '^(temperature|voltage|fan|current|power)$';
|
||||
$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'],
|
||||
],
|
||||
'psu.backup' => [
|
||||
['true', 'OK'],
|
||||
['false', 'CRITICAL'],
|
||||
],
|
||||
};
|
||||
|
||||
$self->{components_path} = 'network::mikrotik::snmp::mode::components';
|
||||
$self->{components_module} = ['current', 'fan', 'power', 'temperature', 'voltage'];
|
||||
$self->{components_module} = ['current', 'fan', 'psu', 'temperature', 'voltage'];
|
||||
}
|
||||
|
||||
sub snmp_execute {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oid_mtxrHealth = '.1.3.6.1.4.1.14988.1.1.3';
|
||||
$self->{snmp} = $options{snmp};
|
||||
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||
$self->{results} = $self->{snmp}->get_table(oid => $oid_mtxrHealth);
|
||||
}
|
||||
|
||||
sub new {
|
||||
|
@ -49,10 +60,9 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
});
|
||||
|
||||
$options{options}->add_options(arguments => {
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -86,7 +96,6 @@ Can be specific or global: --absent-problem=fan,1
|
|||
Return an error if no compenents are checked.
|
||||
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||
|
||||
|
||||
=item B<--warning>
|
||||
|
||||
Set warning threshold for 'temperature', 'fan', 'voltage' (syntax: type,regexp,threshold)
|
||||
|
|
Loading…
Reference in New Issue