mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-28 08:04:36 +02:00
harden snmp request (Fix #880)
This commit is contained in:
parent
c07b2e9e78
commit
f58cd01486
@ -324,6 +324,19 @@ sub get_leef {
|
|||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Some equipments gives a partial response and no error.
|
||||||
|
# We look the last value if it's empty or not
|
||||||
|
if (scalar(@$vb) && (scalar(@{@$vb[-1]}) < 3)) {
|
||||||
|
next if ($self->{snmp_autoreduce} == 1 && $self->autoreduce_leef(current => $entry) == 0);
|
||||||
|
if ($dont_quit == 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "SNMP partial response. Please try --snmp-autoreduce option");
|
||||||
|
$self->{output}->option_exit(exit_litteral => "SNMP partial response");
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->set_error(error_status => -1, error_msg => $msg);
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $entry (@$vb) {
|
foreach my $entry (@$vb) {
|
||||||
if ($#$entry < 3) {
|
if ($#$entry < 3) {
|
||||||
# Can be snmpv1 not find
|
# Can be snmpv1 not find
|
||||||
@ -661,7 +674,6 @@ sub set {
|
|||||||
# 2 noSuchName Variable inexistante.
|
# 2 noSuchName Variable inexistante.
|
||||||
|
|
||||||
my $msg = 'SNMP SET Request : ' . $self->{session}->{ErrorStr};
|
my $msg = 'SNMP SET Request : ' . $self->{session}->{ErrorStr};
|
||||||
|
|
||||||
if ($dont_quit == 0) {
|
if ($dont_quit == 0) {
|
||||||
$self->{output}->add_option_msg(short_msg => $msg);
|
$self->{output}->add_option_msg(short_msg => $msg);
|
||||||
$self->{output}->option_exit(exit_litteral => $self->{snmp_errors_exit});
|
$self->{output}->option_exit(exit_litteral => $self->{snmp_errors_exit});
|
||||||
@ -729,6 +741,7 @@ sub check_options {
|
|||||||
$self->{subsetleef} = (defined($options{option_results}->{subsetleef}) && $options{option_results}->{subsetleef} =~ /^[0-9]+$/) ? $options{option_results}->{subsetleef} : 50;
|
$self->{subsetleef} = (defined($options{option_results}->{subsetleef}) && $options{option_results}->{subsetleef} =~ /^[0-9]+$/) ? $options{option_results}->{subsetleef} : 50;
|
||||||
$self->{subsettable} = (defined($options{option_results}->{subsettable}) && $options{option_results}->{subsettable} =~ /^[0-9]+$/) ? $options{option_results}->{subsettable} : 100;
|
$self->{subsettable} = (defined($options{option_results}->{subsettable}) && $options{option_results}->{subsettable} =~ /^[0-9]+$/) ? $options{option_results}->{subsettable} : 100;
|
||||||
$self->{snmp_errors_exit} = $options{option_results}->{snmp_errors_exit};
|
$self->{snmp_errors_exit} = $options{option_results}->{snmp_errors_exit};
|
||||||
|
$self->{snmp_autoreduce} = 0;
|
||||||
$self->{snmp_autoreduce_divisor} = 2;
|
$self->{snmp_autoreduce_divisor} = 2;
|
||||||
if (defined($options{option_results}->{snmp_autoreduce})) {
|
if (defined($options{option_results}->{snmp_autoreduce})) {
|
||||||
$self->{snmp_autoreduce} = 1;
|
$self->{snmp_autoreduce} = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user