diff options
author | root <root@frank.tg14.gathering.org> | 2014-04-17 16:10:33 +0200 |
---|---|---|
committer | root <root@frank.tg14.gathering.org> | 2014-04-17 16:11:41 +0200 |
commit | 993f4d4a483bb7be84d812b831f34420c19046f8 (patch) | |
tree | 609c1e4fb41ea7d730b9a29772aa3abbc1e8e525 /include | |
parent | aeb2b20fd863f9f93c815ea0cde06ee12ea1a14a (diff) |
Switch SNMP fetching to be asynchronous.
Diffstat (limited to 'include')
-rw-r--r-- | include/nms.pm | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/include/nms.pm b/include/nms.pm index af7702d..e93f7d0 100644 --- a/include/nms.pm +++ b/include/nms.pm @@ -111,7 +111,9 @@ sub switch_disconnect { } sub snmp_open_session { - my ($ip, $community) = @_; + my ($ip, $community, $async) = @_; + + $async //= 0; my %options = (UseEnums => 1); if ($ip =~ /:/) { @@ -141,10 +143,10 @@ sub snmp_open_session { } my $session = SNMP::Session->new(%options); - if (defined($session) && defined($session->getnext('sysDescr'))) { + if (defined($session) && ($async || defined($session->getnext('sysDescr')))) { return $session; } else { - die 'Could not open SNMP session'; + die 'Could not open SNMP session to ' . $ip; } } |