Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Odd SNMP module behavior

by joe_tseng (Novice)
on Sep 14, 2012 at 18:50 UTC ( #993776=perlquestion: print w/ replies, xml ) Need Help??
joe_tseng has asked for the wisdom of the Perl Monks concerning the following question:

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

Comment on Odd SNMP module behavior
Select or Download Code
Re: Odd SNMP module behavior
by irirgem (Novice) on Sep 15, 2012 at 12:55 UTC

    So, Not that I don't think you have, but the question needs to be asked...

    Have you made sure the devices you are trying to use SNMPv1 from have it available?
    For instance... Doing something like printing out each device into a log file to see the attempt to pull something simple like sysName or sysUpTime and showing pass/fail or the return value in blocking mode?

    This way you could create a baseline or proof that the at the least it works on all the devices you are attempting to gather information from.

      I did some more reading and the feature you're describing (in Net::SNMP) doesn't seem to be available in Net-SNMP (which is what we're currently using). And it seems I was mistaken in the understanding that Net::SNMP did not support v3

      I'll update the script using the other module and I'll report back later with my findings.

      After some more googling it seems SNMP (using Net-SNMP) lacks blocking mode, but Net::SNMP does. If I'm wrong pls point me in the right direction.

      That said, I found a ton of examples online but they're not entirely helpful to me. I have a vendor's MIB file and I want to:

      • Read in and parse the MIB file
      • Loop through the resulting collection and collect numbers
      The examples I've found all utilize single OIDs. I think SNMP has a built-in parser, but Net::SNMP doesn't. Can anyone recommend a parsing module I can use?

      I had said before I was very green re: this topic and this is epitomizes my experience. After alot of reading I discovered the script I was using to parse through the MIB entries and retrieve values was written using bulkwalk, and I tried it using both v1 and v3. And in addition, it did not work because bulk operations do not work when using v1. I'd have to rewrite our subroutine to replicate bulk functionality when using v1.

      I hope other newbies figure this out sooner than I did.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://993776]
Approved by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-08-28 04:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (256 votes), past polls