Sébastien Aperghis-Tramoni
and 1 contributors


SNMP::ToolBox - Set of SNMP-related utilities


Version 0.03


    use SNMP::ToolBox;

    # sort a list of OIDs
    @oid_list = sort by_oid @oid_list;

    # OID-encode a string
    $idx = oid_encode($name);


This module contains a set of functions useful for writing SNMP-related programs and modules: by_oid, find_next_oid(), oid_encode().


The following functions are exported by default:

    by_oid  find_next_oid  oid_encode



Sub-routine suitable for being used with sort for sorting OIDs. Two implementations are included in this module: a classical one, by splitting the OIDs and comparing each pair of components, and another, by evaluating the OIDs as Perl v-strings. The fastest one for the running version of Perl will be used.


    @oid_list = sort by_oid @oid_list;

Even though the implementations proposed in this module are pretty good, it is suggested to use Sort::Key::OID's oidsort() when possible, for it is roughly 40-50 times faster. Here is an example on how to always use the best function available:

    use constant HAVE_SORT_KEY_OID
        => eval "use Sort::Key::OID 0.04 'oidsort'; 1" ? 1 : 0;

    @oid_list = HAVE_SORT_KEY_OID
              ? oidsort(@oid_list)
              : sort by_oid @oid_list;

Using a constant allows the Perl compiler to optimise away the dead code early.


Generic implementation of the algorithm to find the OID following a given one in an ordered list of OIDs. Typically needed for implementing a "getnext" feature in nearly any kind of server-side SNMP extension (pass_persist, SMUX, AgentX, etc).

Expects the list of OIDs as an arrayref, the OID to request against and an optional context. Returns the appropriate "next" OID or the string "NONE".


1. (mandatory) reference to an array containing the list of OIDs
2. (optional) OID to request against
3. (optional) OID context; when given, no OID outside of this contexte will be returned


    my $oid = $walk_base;

    while ($oid ne "NONE") {
        $oid = get_next_oid(\@oid_list, $oid, $walk_base);
        # ...


Returns the OID-encoded equivalent of the string given in argument.


    my $idx = oid_encode($name);


You can find documentation for this module with the perldoc command.

    perldoc SNMP::ToolBox

You can also look for information at:


Please report any bugs or feature requests to bug-snmp-toolbox at rt.cpan.org, or through the web interface at https://rt.cpan.org/Public/Dist/Display.html?Name=SNMP-ToolBox. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


Sébastien Aperghis-Tramoni <sebastien at aperghis.net>


Copyright 2011 Sebastien Aperghis-Tramoni.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.