From 993f4d4a483bb7be84d812b831f34420c19046f8 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 17 Apr 2014 16:10:33 +0200 Subject: Switch SNMP fetching to be asynchronous. --- include/nms.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'include/nms.pm') 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; } } -- cgit v1.2.3