(core) add debug snmp (#3541)

This commit is contained in:
qgarnier 2022-03-11 11:36:10 +01:00 committed by GitHub
parent 492a2b393c
commit 802781b019

View File

@ -372,6 +372,8 @@ sub get_leef {
$self->{output}->option_exit(exit_litteral => $self->{snmp_errors_exit}); $self->{output}->option_exit(exit_litteral => $self->{snmp_errors_exit});
} }
$self->debug(results => $results) if ($self->{output}->is_debug());
return $results; return $results;
} }
@ -548,6 +550,8 @@ sub get_multiple_table {
} }
} }
$self->debug(results => $results) if ($self->{output}->is_debug());
return $results; return $results;
} }
@ -662,6 +666,8 @@ sub get_table {
$self->{output}->option_exit(exit_litteral => $self->{snmp_errors_exit}); $self->{output}->option_exit(exit_litteral => $self->{snmp_errors_exit});
} }
$self->debug(results => $results) if ($self->{output}->is_debug());
return $results; return $results;
} }
@ -924,6 +930,20 @@ sub map_instance {
return $results; return $results;
} }
sub debug {
my ($self, %options) = @_;
foreach my $oid1 ($self->oid_lex_sort(keys %{$options{results}})) {
if (ref($options{results}->{$oid1}) eq 'HASH') {
foreach my $oid2 ($self->oid_lex_sort(keys %{$options{results}->{$oid1}})) {
$self->{output}->output_add(long_msg => $oid2 . ' = ' . (defined($options{results}->{$oid1}->{$oid2}) ? $options{results}->{$oid1}->{$oid2} : 'undef'), debug => 1);
}
} else {
$self->{output}->output_add(long_msg => $oid1 . ' = ' . (defined($options{results}->{$oid1}) ? $options{results}->{$oid1} : 'undef'), debug => 1);
}
}
}
sub oid_lex_sort { sub oid_lex_sort {
my $self = shift; my $self = shift;