We're working on a script using Net-SNMP that will talk to devices using both SNMPv1 and v3. (The plan is to automate the device configurations en masse to use v3.) We're coming across a very strange problem where the script gets hung after we issue bulkwalk commands followed by a MainLoop call:

foreach my $host (@{$hashRef->{hostArray}}){ printf "Starting SNMP bulkwalk for %s\n", $host if($DEBUG); $hashRef->{config}->{DestHost} = $host; my $session = SNMP::Session->new( %{$hashRef->{config}} ); die("No session\n") if(!$session); $session->bulkwalk($hashRef->{snmpSingle}, $hashRef->{snmpBulk +}, $hashRef->{varList}, [\&snmpCallback, $session, $host, \$arraySize +, \%snmpData]); } print "Just before Main Loop\n"; SNMP::MainLoop();

We're getting this running v3 which is behaving as predicted:

trace: _callback_lock(): callback.c, 130: 9:callback:lock: locked (LIB,SESSION_INIT) trace: snmp_call_callbacks(): callback.c, 322: callback: START calling callbacks for maj=0 min=5 trace: snmp_call_callbacks(): callback.c, 336: callback: calling a callback for maj=0 min=5 trace: snmp_call_callbacks(): callback.c, 348: callback: END calling callbacks for maj=0 min=5 (1 called) trace: _callback_unlock(): callback.c, 164: 9:callback:lock: unlocked (LIB,SESSION_INIT) trace: snmp_sess_add_ex(): snmp_api.c, 1683: snmp_sess_add: adding v3 session -- maybe engineID probe now trace: usm_get_user(): snmpusm.c, 2994: usm: getting user trace: snmpv3_engineID_probe(): snmp_api.c, 1409: snmp_api: probing for engineID... trace: snmpv3_build(): snmp_api.c, 2330: snmp_build: Building SNMPv3 message (secName:"dcosnmpadmin", secLevel: +noAuthNoPriv)... <snip>

But when I run it using v1 it hangs:

trace: _callback_lock(): callback.c, 130: 9:callback:lock: locked (LIB,SESSION_INIT) trace: snmp_call_callbacks(): callback.c, 322: callback: START calling callbacks for maj=0 min=5 trace: snmp_call_callbacks(): callback.c, 336: callback: calling a callback for maj=0 min=5 trace: snmp_call_callbacks(): callback.c, 348: callback: END calling callbacks for maj=0 min=5 (1 called) trace: _callback_unlock(): callback.c, 164: 9:callback:lock: unlocked (LIB,SESSION_INIT) trace: _sess_async_send(): snmp_api.c, 5067: sess_async_send: encoding failure trace: snmp_sess_select_info2(): snmp_api.c, 6188: sess_select: for all sessions: 4 sess_select: blocking:no session requests or alarms.

And it ends there. El Goog did not return anything helpful with the msgs from STDERR.

Here's the output from STDOUT:

trace: _callback_unlock(): callback.c, 164: 9:callback:lock: unlocked (LIB,SESSION_INIT) trace: _sess_async_send(): snmp_api.c, 5067: sess_async_send: encoding failure Just before Main Loop trace: snmp_sess_select_info2(): snmp_api.c, 6188: sess_select: for all sessions: 4 sess_select: blocking:no session requests or alarms.

If anyone has a clue as what's going on pls share it with me - I'd be very appreciative!!!

- Joe


In reply to Odd SNMP module behavior by joe_tseng

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.