in reply to Error handling in AnyEvent::SNMP

can you try replacing the $cv->begin, $cv->end with a single $cv->send where the $cv->end is?

Additionally, can you check the return of get_table(), if I read the following right:

When a Net::SNMP object is created having non-blocking behavior, the invocation of a method associated with the object returns immediately, allowing the flow of the code to continue. When a method is invoked that would initiate a SNMP protocol exchange requiring a response, either a true value (i.e. 0x1) is returned immediately or the undefined value is returned if there was a failure. The error() method can be used to determine the cause of the failure.

bw, bliako

Replies are listed 'Best First'.
Re^2: Error handling in AnyEvent::SNMP
by mmoorreett (Acolyte) on May 28, 2021 at 20:31 UTC
    Thanks, but that doesn't work, it only makes the snmp request on the first OID in the loop
    if I force an error, not using an event loop (just snmp non-blocking mode) for example,
    $session->get_table( -baseoid => $snmp_table, -maxrepetitions => 1, -callback => sub{ #print "get_sub\n" +; $hosts{$host}{oid_ +results_table}->{$snmp_table}= &snmp_collect(@_); #$cv->end; } )
    The error The max-repetitions argument is not applicable when using SNMPv1 is returned
    When implemented in the AnyEvent loop the script hangs. Any ideas?

      where is the $cv->send ?