fix(qnap/snmp): minor errors (#2859)
This commit is contained in:
parent
743552a46f
commit
2b9ebf3bc9
|
@ -117,7 +117,7 @@ sub check_fan_ex {
|
|||
|
||||
my $snmp_result = $self->{snmp}->get_table(
|
||||
oid => '.1.3.6.1.4.1.24681.1.4.1.1.1.1.2.2', # systemFan2Table
|
||||
start => $mapping->{ex}->{status}->{oid}
|
||||
start => $mapping->{ex}->{description}->{oid}
|
||||
);
|
||||
check_fan_result($self, type => 'ex', snmp_result => $snmp_result);
|
||||
}
|
||||
|
|
|
@ -23,11 +23,6 @@ package storage::qnap::snmp::mode::components::temperature;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $oid_CPU_Temperature_entry = '.1.3.6.1.4.1.24681.1.2.5';
|
||||
my $oid_CPU_Temperature = '.1.3.6.1.4.1.24681.1.2.5.0';
|
||||
my $oid_SystemTemperature_entry = '.1.3.6.1.4.1.24681.1.2.6';
|
||||
my $oid_SystemTemperature = '.1.3.6.1.4.1.24681.1.2.6.0';
|
||||
|
||||
my $mapping = {
|
||||
legacy => {
|
||||
cpu_temp => { oid => '.1.3.6.1.4.1.24681.1.2.5' }, # cpu-Temperature
|
||||
|
@ -49,7 +44,7 @@ sub check_temp_result {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$options{result}->{cpu_temp} = defined($options{result}->{cpu_temp}) ? $options{result}->{cpu_temp} : 'unknown';
|
||||
if ($options{result}->{cpu_temp} =~ /([0-9]+)\s*C/ && !$self->check_filter(section => 'temperature', instance => 'cpu')) {
|
||||
if ($options{result}->{cpu_temp} =~ /([0-9]+)\s*C?/ && !$self->check_filter(section => 'temperature', instance => 'cpu')) {
|
||||
my $value = $1;
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
$self->{output}->output_add(
|
||||
|
@ -76,7 +71,7 @@ sub check_temp_result {
|
|||
}
|
||||
|
||||
$options{result}->{system_temp} = defined($options{result}->{system_temp}) ? $options{result}->{system_temp} : 'unknown';
|
||||
if ($options{result}->{system_temp} =~ /([0-9]+)\s*C/ && !$self->check_filter(section => 'temperature', instance => 'system')) {
|
||||
if ($options{result}->{system_temp} =~ /([0-9]+)\s*C?/ && !$self->check_filter(section => 'temperature', instance => 'system')) {
|
||||
my $value = $1;
|
||||
$self->{components}->{temperature}->{total}++;
|
||||
$self->{output}->output_add(
|
||||
|
@ -120,7 +115,7 @@ sub check_temp {
|
|||
oids => [ map($_->{oid} . '.0', values(%{$mapping->{ex}}), values(%{$mapping->{legacy}})) ],
|
||||
);
|
||||
my $result = $self->{snmp}->map_instance(mapping => $mapping->{ex}, results => $snmp_result, instance => 0);
|
||||
if (defined($result->{cpu_tem})) {
|
||||
if (defined($result->{cpu_temp})) {
|
||||
check_temp_result($self, result => $result);
|
||||
} else {
|
||||
$result = $self->{snmp}->map_instance(mapping => $mapping->{legacy}, results => $snmp_result, instance => 0);
|
||||
|
|
|
@ -126,15 +126,20 @@ sub check_memory {
|
|||
my $result = $options{snmp}->map_instance(mapping => $mapping->{ $options{type} }, results => $options{snmp_result}, instance => 0);
|
||||
return 0 if (!defined($result->{ram_free}));
|
||||
|
||||
$result->{ram_total} = $self->convert_bytes(value => $result->{ram_total});
|
||||
$result->{ram_free} = $self->convert_bytes(value => $result->{ram_free});
|
||||
$self->{ram} = {
|
||||
total => $result->{ram_total},
|
||||
used => $result->{ram_total} - $result->{ram_free},
|
||||
free => $result->{ram_free},
|
||||
prct_used => 100 - ($result->{ram_free} * 100 / $result->{ram_total}),
|
||||
prct_free => $result->{ram_free} * 100 / $result->{ram_total}
|
||||
};
|
||||
if (defined($options{convert})) {
|
||||
$result->{ram_total} = $self->convert_bytes(value => $result->{ram_total});
|
||||
$result->{ram_free} = $self->convert_bytes(value => $result->{ram_free});
|
||||
}
|
||||
|
||||
if (defined($result->{ram_total}) && $result->{ram_total} > 0) {
|
||||
$self->{ram} = {
|
||||
total => $result->{ram_total},
|
||||
used => $result->{ram_total} - $result->{ram_free},
|
||||
free => $result->{ram_free},
|
||||
prct_used => 100 - ($result->{ram_free} * 100 / $result->{ram_total}),
|
||||
prct_free => $result->{ram_free} * 100 / $result->{ram_total}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
|
@ -145,8 +150,8 @@ sub manage_selection {
|
|||
nothing_quit => 1
|
||||
);
|
||||
$self->check_memory(snmp => $options{snmp}, type => 'ex', snmp_result => $snmp_result);
|
||||
$self->check_memory(snmp => $options{snmp}, type => 'es', snmp_result => $snmp_result);
|
||||
$self->check_memory(snmp => $options{snmp}, type => 'legacy', snmp_result => $snmp_result);
|
||||
$self->check_memory(snmp => $options{snmp}, type => 'es', snmp_result => $snmp_result, convert => 1);
|
||||
$self->check_memory(snmp => $options{snmp}, type => 'legacy', snmp_result => $snmp_result, convert => 1);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Loading…
Reference in New Issue