Perl FAQ 1.22: Is there an SNMP aware Perl?

Perl FAQ 1.22

Is there an SNMP aware Perl?

snmperl was written by Guy Streeter (, and was posted in late February 1993 to comp.protocols.snmp. It can be found archived at one of two (known) places:

Location: /pub/net/snmp
       FILE -rw-rw-r--       3407  Aug 11 1992  snmperl.README
       FILE -rw-r--r--      17678  Aug 11 1992  snmperl.tar.Z

Location: /pub/perl/scripts/snmp

Here is the gist of the README:

This directory contains the source code to add callable C subroutines to perl. The subroutines implement the SNMP functions ``get'', ``getnext'', and ``set''. They use the freely-distributable SNMP package (version 1.1b) from CMU.

USE: There are four subroutines defined in the callable interface: snmp_get, snmp_next, snmp_set, and snmp_error.

snmp_get and snmp_next implement the GET and GETNEXT operations, respectively. The first two calling arguments are the hostname and Community string. The IP address of the host, as a dotted-quad ASCII string, may be used as the hostname. The rest of the calling arguments are a list of variables. See the CMU package documentation for how variables may be specified.

snmp_set also takes hostname and Community string as arguments. The remaining arguments are a list of triples consisting of variable name, variable type, and value. The variable type is a string, such as ``INTEGER'' or ``IpAddress''.

snmp_get, snmp_next, and snmp_set return a list containing alternating variables and values. snmp_get and snmp_next will simply omit non-existent variables on return. snmp_set will fail completely if one of the specified variables does not exist (or is read-only).

snmp_error will return a text string containing some error information about the most recent snmp_get|next|set call, if it had an error.

I didn't find all the places where the CMU library writes to stderr or calls exit() directly.

The changes I made to mib.c involve the formatting of variable values for return to the caller. I took out the descriptive prefix so the string contains only the value.

Enumerated types are returned as a string containing the symbolic representation followed in parentheses by the numeric.


perl and the CMU SNMP package have their own statements. Read them. The work I've done is free and clear. Just don't say you wrote it if you didn't, and don't say I wrote it if you change it.

    Guy Streeter
    April 1, 1992 (not a joke!)

Other resources at this site: