Which Perl module should I use

From Net-SNMP Wiki
Revision as of 18:41, 23 January 2008 by MikeAyers (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Good Answer

This is a Good Answer article. It was likely created as a response to a question on a Net-SNMP Mailing List and written up here for others to see. It likely covers material not yet in the FAQ or in the Tutorial but may someday be moved there

Question

Which Perl SNMP module should I use?

Answer

There are basically two alternative SNMP perl modules. One is a "pure-perl" implementation, called "Net::SNMP" and develeped by David Town. The other is a perl interface to the Net-SNMP C libraries, which comes as two separate packages - SNMP and Net-SNMP. These are therefore closely linked with the C library code.

The SNMP::Info module is a higher-level convenience module, using the Net-SNMP perl modules (i.e. SNMP/Net-SNMP).

The SNMP::Info documentation tells you not to install SNMP or Net::SNMP from CPAN - but the reasons are different for each of these two packages.

You shouldn't install Net::SNMP because the SNMP::Info module is not written to use the Net::SNMP api. It's the wrong package for this module, so there's no point in installing it.

You *should* install SNMP/Net-SNMP - but not from CPAN. Because these modules are closely linked with the C library, they rely on having the correct version of the library installed. There can be minor changes to the library internals from one release to another, which wouldn't affect most applications but can break the perl internals.

The safest approach is to install the SNMP perl modules from the same Net-SNMP distribution as the C libraries that you are using. That's the most reliable way to ensure compatibility.

If you are using a vendor-supplied version of the Net-SNMP suite, then they ought to provide a package that includes the perl APIs as well. If you compiled things yourself from source, then

./configure --with-perl-modules

will build the correct perl API modules as well.