Why does this SNMP session not die? It continues ad infinitum... well, a long time at least, ignoring the timeouts, retries etc.

I am pointing it to an interface that is pingable, but the snmp agent is not available to that interface at the time (this is a system where there are multiple management cards, in a high availability type system, and only one is available at a time - I am trying to get a clean failure, so I can move on to the next interface - and this works perfectly when talking to an interface that is active, ie has the mgmt client avialable on it). To fully appreciate the predicament, the interfaces are always active when in a standby mode... otherwise I would just Net::Ping them first... but shouldn't the timeouts force the snmpsession to fail?

sample code: my ($hosted,$community) = @_; my $sversion = "v2c"; my $stimeout = 8; my $sretries = 1; print "trying SNMP on $hosted ...\n"; my ($snmpsession, $snmperror) = Net::SNMP->session( -hostname => $hosted, -version => $sversion, -timeout => $stimeout, -retries => $sretries, -community => $community, -debug => "DEBUG_ALL", ); Watching the debug output, I see the retries expire, debug: [342] Net::SNMP::Dispatcher::_transport_timeout(): retries left + 0 and then it ramps right up again! error: [2361] Net::SNMP::__ANON__(): No response from remote host "myo +bfuscatedhostname" debug: [516] Net::SNMP::Dispatcher::_event_delete(): deleted [ARRAY(0x +9c4354)], list is now empty Error: No response from remote host "m +yobfuscatedhostname". debug: [1057] Net::SNMP::Message::_prepare_object_identifier(): leadin +g dot present debug: [439] Net::SNMP::Dispatcher::_event_insert(): created new head +and tail [ARRAY(0x9c4384)] debug: [199] Net::SNMP::Dispatcher::register(): added handler for desc +riptor [8] debug: [461] Net::SNMP::Dispatcher::_event_insert(): modified tail [AR +RAY(0x9c45c4)] debug: [534] Net::SNMP::Dispatcher::_event_delete(): deleted [ARRAY(0x +9c4204)], defined new head [ARRAY(0x9c45c4)] debug: [595] Net::SNMP::Dispatcher::_event_handle(): event [ARRAY(0x9c +45c4)], timeout = 7.9997

I am hoping to have a way to fail this gracefully, I can take it from there... Any ideas?


In reply to Net::SNMP ignoring retries & timeouts by Mickey_C

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.