Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Net::SNMP vs SNMP, and MIBs

by hatter (Pilgrim)
on Apr 15, 2005 at 15:02 UTC ( #448203=perlquestion: print w/replies, xml ) Need Help??

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

There doesn't seem to be much mention of the SNMP::* modules around, but they handle MIBs to I don't have to look up numbers or comment what the numbers mean to save the next person doing so, and can generally be less cryptic. Also, SNMP hasn't been updated since 2000, whereas Net::SNMP has been revised much more recently; is it that SNMP just works ? What are the caveats of picking one over the other ? I was contemplating using the obviously-maintained Net::SNMP and using SNMP for resolving numbers to names and vice versa, but that sounds a bit of a strange thing to do if SNMP can do it all.

the hatter

Replies are listed 'Best First'.
Re: Net::SNMP vs SNMP, and MIBs
by gam3 (Curate) on Apr 15, 2005 at 15:46 UTC
    The SNMP package is part of the net-snmp distribution and uses the net-snmp libraries to access snmp. Where Net::SNMP is written in pure perl and accesses snmp directly using IO::Socket::INET.

    I would use SNMP unless you don't have net-snmp on your computer, or can't get the perl bindings to libnetsnmp to complile on your computer.

    -- gam3
    A picture is worth a thousand words, but takes 200K.
Re: Net::SNMP vs SNMP, and MIBs
by Anonymous Monk on Apr 15, 2005 at 21:10 UTC
    i believe the SNMP module is maintained within the net-snmp distribution. so the version on CPAN may not be the most recent. i usually use SNMP over Net::SNMP. because SNMP uses the same shared libraries as the net-snmp cli tools (snmp{set,get,walk,translate,...}). so if i have any problems i can debug using the cli tools and then easily convert to Perl later. SNMP also does all of the MIB translation stuff you could ever want. also if you have any problems with devices or MIBs you can duplicate the problem with the cli tools and then when you talk to the vendor you can say that you're having problems while using common tools instead of saying that you're having problems using some odd Perl module.
Re: Net::SNMP vs SNMP, and MIBs
by 5mi11er (Deacon) on Apr 15, 2005 at 18:09 UTC
    I've got the following comment in one of the programs I'm attempting to actively work on at the moment. The comment was made by me, but it was made too long ago to remember exactly why I said that...
    use SNMP; #pretty much only used for Mib translations use Net::SNMP qw(snmp_dispatcher ticks_to_time);
    Later I'm using the following methods from each package:
    $sysUpTime = SNMP::translateObj('sysUpTime.0'); # Create a session for this host my ($session, $error) = Net::SNMP->session( -hostname => $box{ipadd}, -community => $community_string, -port => 161, -nonblocking => 0x1, # Create non-blocking object +s -translate => [ -timeticks => 0x0 # Turn off so sysUpTi +me is numeric ] ); if (!defined($session)) { $err++; logit $DBG, sprintf("ERROR: %s.\n", $error); return 0; }
    So, from that, either I got what I wanted from each package and was to stuborn to try to learn if one or the other was enough, or they were complementary, and I couldn't do what I wanted from only one. My tuits are missing today or I'd have looked it up by now...


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://448203]
Approved by xorl
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2022-05-20 12:11 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (73 votes). Check out past polls.