try to update synology

This commit is contained in:
garnier-quentin 2020-07-08 12:01:07 +02:00
parent adc9fbbcf3
commit 3d378d80b1
4 changed files with 25 additions and 14 deletions

View File

@ -34,9 +34,7 @@ my $oid_fan = '.1.3.6.1.4.1.6574.1.4';
sub load { sub load {
my ($self) = @_; my ($self) = @_;
push @{$self->{request}}, { push @{$self->{request_leef}}, $mapping->{synoSystemsystemFanStatus}->{oid} . '.0', $mapping->{synoSystemcpuFanStatus}->{oid} . '.0';
oid => $oid_fan
};
} }
sub check { sub check {
@ -45,9 +43,9 @@ sub check {
$self->{output}->output_add(long_msg => "Checking cpu fan"); $self->{output}->output_add(long_msg => "Checking cpu fan");
$self->{components}->{fan} = {name => 'fan', total => 0, skip => 0}; $self->{components}->{fan} = {name => 'fan', 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}->{$oid_fan}, instance => '0'); my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results_leef}, instance => '0');
if (!$self->check_filter(section => 'fan', instance => 'cpu')) { if (defined($result->{synoSystemcpuFanStatus}) && !$self->check_filter(section => 'fan', instance => 'cpu')) {
$self->{components}->{fan}->{total}++; $self->{components}->{fan}->{total}++;
$self->{output}->output_add( $self->{output}->output_add(
@ -65,7 +63,7 @@ sub check {
} }
} }
if (!$self->check_filter(section => 'fan', instance => 'system')) { if (defined($result->{synoSystemsystemFanStatus}) && !$self->check_filter(section => 'fan', instance => 'system')) {
$self->{components}->{fan}->{total}++; $self->{components}->{fan}->{total}++;
$self->{output}->output_add( $self->{output}->output_add(
long_msg => sprintf( long_msg => sprintf(

View File

@ -32,7 +32,7 @@ my $mapping = {
sub load { sub load {
my ($self) = @_; my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{synoSystempowerStatus}->{oid} }; push @{$self->{request_leef}}, $mapping->{synoSystempowerStatus}->{oid} . '.0';
} }
sub check { sub check {
@ -41,9 +41,12 @@ sub check {
$self->{output}->output_add(long_msg => "Checking power supply"); $self->{output}->output_add(long_msg => "Checking power supply");
$self->{components}->{psu} = {name => 'psu', total => 0, skip => 0}; $self->{components}->{psu} = {name => 'psu', total => 0, skip => 0};
return if ($self->check_filter(section => 'psu')); return if ($self->check_filter(section => 'psu'));
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results_leef}, instance => '0');
return if (!defined($result->{synoSystempowerStatus}));
$self->{components}->{psu}->{total}++; $self->{components}->{psu}->{total}++;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{synoSystempowerStatus}->{oid}}, instance => '0');
$self->{output}->output_add( $self->{output}->output_add(
long_msg => sprintf( long_msg => sprintf(
"power supply status is %s.", "power supply status is %s.",

View File

@ -26,13 +26,13 @@ use warnings;
my $map_status = { 1 => 'Normal', 2 => 'Failed' }; my $map_status = { 1 => 'Normal', 2 => 'Failed' };
my $mapping = { my $mapping = {
synoSystemsystemStatus => { oid => '.1.3.6.1.4.1.6574.1.1', map => $map_status } synoSystemsystemStatus => { oid => '.1.3.6.1.4.1.6574.1.1', map => $map_status }
}; };
sub load { sub load {
my ($self) = @_; my ($self) = @_;
push @{$self->{request}}, { oid => $mapping->{synoSystemsystemStatus}->{oid} }; push @{$self->{request_leef}}, $mapping->{synoSystemsystemStatus}->{oid} . '.0';
} }
sub check { sub check {
@ -41,9 +41,12 @@ sub check {
$self->{output}->output_add(long_msg => "Checking system partition status"); $self->{output}->output_add(long_msg => "Checking system partition status");
$self->{components}->{system} = {name => 'system', total => 0, skip => 0}; $self->{components}->{system} = {name => 'system', total => 0, skip => 0};
return if ($self->check_filter(section => 'system')); return if ($self->check_filter(section => 'system'));
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results_leef}, instance => '0');
return if (!defined($result->{synoSystemsystemStatus}));
$self->{components}->{system}->{total}++; $self->{components}->{system}->{total}++;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{synoSystemsystemStatus}->{oid}}, instance => '0');
$self->{output}->output_add( $self->{output}->output_add(
long_msg => sprintf( long_msg => sprintf(
"system partition status is %s.", "system partition status is %s.",

View File

@ -72,13 +72,20 @@ sub set_system {
$self->{components_path} = 'storage::synology::snmp::mode::components'; $self->{components_path} = 'storage::synology::snmp::mode::components';
$self->{components_module} = ['psu', 'fan', 'disk', 'raid', 'system']; $self->{components_module} = ['psu', 'fan', 'disk', 'raid', 'system'];
$self->{request_leef} = [];
} }
sub snmp_execute { sub snmp_execute {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{snmp} = $options{snmp}; $self->{snmp} = $options{snmp};
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request}); if (scalar(@{$self->{request}}) > 0) {
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
}
if (scalar(@{$self->{request_leef}}) > 0) {
$self->{results_leef} = $self->{snmp}->get_leef(oids => $self->{request_leef});
}
} }
sub new { sub new {