splinky has asked for the wisdom of the Perl Monks concerning the following question:

I need to write some Perl code to control a piece of equipment via SNMP. So, I did the logical thing... searched for SNMP on CPAN. Yikes! Too many options!

So, I'm looking for recommendations on easy-to-use and reliable SNMP modules. I'm leaning towards Net-SNMP (not to be confused with Net::SNMP), but ISTR having trouble getting it to work last time I messed with it.

Anyway, please expound. And thanks in advance.

Replies are listed 'Best First'.
Re: Best module(s) for SNMP?
by NetWallah (Canon) on Feb 10, 2006 at 01:28 UTC
    It depends on your objectives - if this is a one-time request for simple info, your Net-SNMP approach is fine.

    If, this is a development effort to monitor or modify device parameters with dependencies on various factors - this needs programming, and Net::SNMP, though not the friendliest, is very powerful.

    You could try SNMP::Simple, although the author recommends against it being a starting point. If you just ineed Interface info, Net::SNMP::Interfaces works great.

    On request, I'm willing to share code that uses SNMP (perL) for monitoring switches, getting ARP info, and diagnose Spanning-tree issues.

         "For every complex problem, there is a simple answer ... and it is wrong." --H.L. Mencken

      My application is automated testing of the SNMP interface for a piece of equipment my company sells, so it'll probably be pretty rigorous if I'm doing my job correctly :-) Lots of table additions and deletions, that's for sure.

      Interesting that you mention Net::SNMP. That's the first thing I looked at, but I stopped looking when I realized that it didn't know anything about MIBs. If I want to get sysDescr.0 without having to know that it's .1.3.6.1.2.1.1.1.0, how do I go about that with Net::SNMP?

        Take a look at SNMP::MIB::Compiler.
        use SNMP::MIB::Compiler; my $mib = new SNMP::MIB::Compiler; $mib->add_path('./mibs', '/usr/share/snmp/mibs'); $mib->add_extension('', '.mib', '.my', '.txt'); $mib->repository('./out'); # only accept SMIv2 MIBs $mib->{'accept_smiv1'} = 0; $mib->{'accept_smiv2'} = 1; # no debug $mib->{'debug_lexer'} = 0; $mib->{'debug_recursive'} = 0; # store compiled MIBs into files $mib->{'make_dump'} = 1; # read compiled MIBs $mib->{'use_dump'} = 1; # follow IMPORTS clause while compiling $mib->{'do_imports'} = 1; # load a precompiled MIB $mib->load('SNMPv2-MIB'); print $mib->resolve_oid('sysDescr'), ".0\n";
        UPDATE: show sysDescr.
        -- gam3
        A picture is worth a thousand words, but takes 200K.
Re: Best module(s) for SNMP?
by gam3 (Curate) on Feb 10, 2006 at 06:06 UTC
    I have always liked using the net-snmp SNMP interface. This is certainly a good choice if you have net-snmp loaded on you computers already. Look at the example files for help with the interface.
    -- gam3
    A picture is worth a thousand words, but takes 200K.