enhance mikrotik (#2299)

This commit is contained in:
qgarnier 2020-10-28 15:58:46 +01:00 committed by GitHub
parent a6940392bf
commit 4509782456
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 51 deletions

View File

@ -68,15 +68,7 @@ sub check {
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,
instance => 1,
name => 'system'
);
}
my $gauge_ok = 0;
foreach (keys %{$self->{results}}) {
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dA');
@ -88,6 +80,16 @@ sub check {
instance => $1,
name => $result->{name}
);
$gauge_ok = 1;
}
if ($gauge_ok == 0 && defined($result->{mtxrHlCurrent}) && $result->{mtxrHlCurrent} =~ /[0-9]+/) {
check_current(
$self,
value => $result->{mtxrHlCurrent} / 100,
instance => 1,
name => 'system'
);
}
}

View File

@ -67,19 +67,22 @@ sub check {
return if ($self->check_filter(section => 'fan'));
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]+/) {
check_fan($self, value => $result->{mtxrHlFanSpeed2}, instance => 2);
}
my $gauge_ok = 0;
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});
$gauge_ok = 1;
}
if ($gauge_ok == 0 && defined($result->{mtxrHlFanSpeed1}) && $result->{mtxrHlFanSpeed1} =~ /[0-9]+/) {
check_fan($self, value => $result->{mtxrHlFanSpeed1}, instance => 1);
}
if ($gauge_ok == 0 && defined($result->{mtxrHlFanSpeed2}) && $result->{mtxrHlFanSpeed2} =~ /[0-9]+/) {
check_fan($self, value => $result->{mtxrHlFanSpeed2}, instance => 2);
}
}

View File

@ -98,15 +98,7 @@ sub check {
check_psu($self, value => $result->{mtxrHlPowerSupplyState}, type => 'primary');
check_psu($self, value => $result->{mtxrHlBackupPowerSupplyState}, type => 'backup');
if (defined($result->{mtxrHlPower}) && $result->{mtxrHlPower} =~ /[0-9]+/) {
check_power(
$self,
value => $result->{mtxrHlPower} / 100,
instance => 1,
name => 'system'
);
}
my $gauge_ok = 0;
foreach (keys %{$self->{results}}) {
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dW');
@ -118,6 +110,16 @@ sub check {
instance => $1,
name => $result->{name}
);
$gauge_ok = 1;
}
if ($gauge_ok == 0 && defined($result->{mtxrHlPower}) && $result->{mtxrHlPower} =~ /[0-9]+/) {
check_power(
$self,
value => $result->{mtxrHlPower} / 100,
instance => 1,
name => 'system'
);
}
}

View File

@ -72,25 +72,7 @@ sub check {
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => 0);
if (defined($result->{mtxrHlTemperature}) && $result->{mtxrHlTemperature} =~ /[0-9]+/) {
check_temperature(
$self,
value => $result->{mtxrHlTemperature} / 10,
instance => 1,
name => 'system',
description => 'system temperature (SoC or PCB)'
);
}
if (defined($result->{mtxrHlProcessorTemperature}) && $result->{mtxrHlProcessorTemperature} =~ /[0-9]+/) {
check_temperature(
$self,
value => $result->{mtxrHlProcessorTemperature} / 10,
instance => 2,
name => 'processor',
description => 'processor temperature'
);
}
my $gauge_ok = 0;
foreach (keys %{$self->{results}}) {
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'celsius');
@ -103,6 +85,26 @@ sub check {
name => $result->{name},
description => "sensor temperature '$result->{name}'"
);
$gauge_ok = 1;
}
if ($gauge_ok == 0 && defined($result->{mtxrHlTemperature}) && $result->{mtxrHlTemperature} =~ /[0-9]+/) {
check_temperature(
$self,
value => $result->{mtxrHlTemperature} / 10,
instance => 1,
name => 'system',
description => 'system temperature (SoC or PCB)'
);
}
if ($gauge_ok == 0 && defined($result->{mtxrHlProcessorTemperature}) && $result->{mtxrHlProcessorTemperature} =~ /[0-9]+/) {
check_temperature(
$self,
value => $result->{mtxrHlProcessorTemperature} / 10,
instance => 2,
name => 'processor',
description => 'processor temperature'
);
}
}

View File

@ -67,15 +67,8 @@ sub check {
return if ($self->check_filter(section => 'voltage'));
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,
instance => 1,
name => 'system'
);
}
my $gauge_ok = 0;
foreach (keys %{$self->{results}}) {
next if (! /^$mapping_gauge->{unit}->{oid}\.(\d+)/);
next if ($map_gauge_unit->{ $self->{results}->{$_} } ne 'dV');
@ -87,6 +80,16 @@ sub check {
instance => $1,
name => $result->{name}
);
$gauge_ok = 1;
}
if ($gauge_ok == 0 && defined($result->{mtxrHlVoltage}) && $result->{mtxrHlVoltage} =~ /[0-9]+/) {
check_voltage(
$self,
value => $result->{mtxrHlVoltage} / 10,
instance => 1,
name => 'system'
);
}
}