Allow cached SNMP community hint to override SNMP version cycle
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
* Correct is_discoverable check in Undiscovered Neighbors report
|
* Correct is_discoverable check in Undiscovered Neighbors report
|
||||||
* Correct macsuck for Q-BRIDGE-MIB based devices
|
* Correct macsuck for Q-BRIDGE-MIB based devices
|
||||||
|
* Allow cached SNMP community hint to override SNMP version cycle
|
||||||
|
|
||||||
2.021000 - 2014-01-08
|
2.021000 - 2014-01-08
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,16 @@ sub _snmp_connect_generic {
|
|||||||
$snmp_args{BulkWalk} = 0;
|
$snmp_args{BulkWalk} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# get the community string(s)
|
||||||
|
my @communities = _build_communities($device, $mode);
|
||||||
|
|
||||||
|
# which SNMP versions to try and in what order
|
||||||
|
my @versions =
|
||||||
|
( check_no($device->ip, 'snmpforce_v3') ? (3)
|
||||||
|
: check_no($device->ip, 'snmpforce_v2') ? (2)
|
||||||
|
: check_no($device->ip, 'snmpforce_v1') ? (1)
|
||||||
|
: (reverse (1 .. (setting('snmpver') || 3))) );
|
||||||
|
|
||||||
# use existing or new device class
|
# use existing or new device class
|
||||||
my @classes = ('SNMP::Info');
|
my @classes = ('SNMP::Info');
|
||||||
if ($device->snmp_class) {
|
if ($device->snmp_class) {
|
||||||
@@ -96,30 +106,22 @@ sub _snmp_connect_generic {
|
|||||||
$snmp_args{AutoSpecity} = 1;
|
$snmp_args{AutoSpecity} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
# which SNMP versions to try and in what order
|
|
||||||
my @versions =
|
|
||||||
( check_no($device->ip, 'snmpforce_v3') ? (3)
|
|
||||||
: check_no($device->ip, 'snmpforce_v2') ? (2)
|
|
||||||
: check_no($device->ip, 'snmpforce_v1') ? (1)
|
|
||||||
: (reverse (1 .. (setting('snmpver') || 3))) );
|
|
||||||
|
|
||||||
# get the community string(s)
|
|
||||||
my @communities = _build_communities($device, $mode);
|
|
||||||
|
|
||||||
my $info = undef;
|
my $info = undef;
|
||||||
|
COMMUNITY: foreach my $comm (@communities) {
|
||||||
|
next unless $comm;
|
||||||
|
|
||||||
VERSION: foreach my $ver (@versions) {
|
VERSION: foreach my $ver (@versions) {
|
||||||
next unless $ver;
|
next unless $ver;
|
||||||
|
|
||||||
|
next if $ver eq 3 and exists $comm->{community};
|
||||||
|
next if $ver ne 3 and !exists $comm->{community};
|
||||||
|
|
||||||
CLASS: foreach my $class (@classes) {
|
CLASS: foreach my $class (@classes) {
|
||||||
next unless $class;
|
next unless $class;
|
||||||
|
|
||||||
COMMUNITY: foreach my $comm (@communities) {
|
|
||||||
next if $ver eq 3 and exists $comm->{community};
|
|
||||||
next if $ver ne 3 and !exists $comm->{community};
|
|
||||||
|
|
||||||
my %local_args = (%snmp_args, Version => $ver);
|
my %local_args = (%snmp_args, Version => $ver);
|
||||||
$info = _try_connect($device, $class, $comm, $mode, \%local_args);
|
$info = _try_connect($device, $class, $comm, $mode, \%local_args);
|
||||||
last VERSION if $info;
|
last COMMUNITY if $info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user