NAME
SNMP::ToolBox - Set of SNMP-related utilities
VERSION
Version 0.01
SYNOPSIS
use SNMP::ToolBox;
# sort a list of OIDs
@oid_list = sort by_oid @oid_list;
# OID-encode a string
$idx = oid_encode($name);
DESCRIPTION
This module contains a set of functions useful for writing SNMP-related programs and modules: by_oid
, find_next_oid()
, oid_encode()
.
EXPORTS
The following functions are exported by default:
by_oid find_next_oid oid_encode
FUNCTIONS
by_oid
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.
Example:
@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.
find_next_oid
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"
.
Arguments:
- 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
Exemple:
my $oid = $walk_base;
while ($oid ne "NONE") {
$oid = get_next_oid(\@oid_list, $oid, $walk_base);
# ...
}
oid_encode
Returns the OID-encoded equivalent of the string given in argument.
Example:
my $idx = oid_encode($name);
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc SNMP::ToolBox
You can also look for information at:
Search CPAN
Meta CPAN
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/Public/Dist/Display.html?Name=SNMP-ToolBox
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
BUGS
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.
AUTHOR
Sébastien Aperghis-Tramoni <sebastien at aperghis.net>
LICENSE AND COPYRIGHT
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.