
SNMP::Extension::PassPersist - Generic pass/pass_persist extension framework for Net-SNMP

This is the documentation of SNMP::Extension::PassPersist version 0.03

# typical setup for a pass programm
use SNMP::Extension::PassPersist;
# create the object
my $extsnmp = SNMP::Extension::PassPersist->new;
# add a few OID entries
$extsnmp->add_oid_entry($oid, $type, $value);
$extsnmp->add_oid_entry($oid, $type, $value);
# run the program
$extsnmp->run;
# typical setup for a pass_persist program
use SNMP::Extension::PassPersist;
my $extsnmp = SNMP::Extension::PassPersist->new(
backend_collect => \&update_tree
);
$extsnmp->run;
sub update_tree {
my ($self) = @_;
# add a serie of OID entries
$self->add_oid_entry($oid, $type, $value);
...
# or directly add a whole OID tree
$self->add_oid_tree(\%oid_tree);
}

This module is a framework for writing Net-SNMP extensions using the pass or pass_persist mechanisms.
When in pass_persist mode, it provides a mechanism to spare ressources by quitting from the main loop after a given number of idle cycles.
This module can use Sort::Key::OID when it is available, for sorting OIDs faster than with the internal pure Perl function.

Creates a new object. Can be given any attributes as a hash or hashref. See "ATTRIBUTES" for the list of available attributes.
Examples:
# for a "pass" command, most attributes are useless
my $extsnmp = SNMP::Extension::PassPersist->new;
# for a "pass_persist" command, you'll usually want to
# at least set the backend_collect callback
my $extsnmp = SNMP::Extension::PassPersist->new(
backend_collect => \&update_tree,
idle_count => 10, # no more than 10 idle cycles
refresh => 10, # refresh every 10 sec
);
This method does the following things:
Then, when in "pass" mode, the corresponding SNMP command is executed, its result is printed on the output filehandle, and run() returns.
When in "pass_persist" mode, run() enters a loop, reading Net-SNMP queries on its input filehandle, processing them, and printing result on its output filehandle. The backend collect callback is called every refresh seconds. If no query is read from the input after idle_count cycles, run() returns.
Add an entry to the OID tree.
Merge an OID tree to the main OID tree, using the same structure as the one of the OID tree itself.

This module's attributes are generated by Class::Accessor, and can therefore be passed as arguments to new() or called as object methods.
Set the code reference for a backend callback that will be called only once, at the beginning of run(), just after parsing the command-line arguments. See also "CALLBACKS".
Set the code reference for a backend callback that will be called every refresh seconds to update the OID tree. See also "CALLBACKS".
Gives access to the internal dispatch table, stored as a hash with the following structure:
dispatch => {
SNMP_CMD => { nargs => NUMBER_ARGS, code => CODEREF },
...
}
where the SNMP command is always in lowercase, nargs gives the number of arguments expected by the command and code the callback reference.
You should not modify this table unless you really know what you're doing.
Get/set the number of idle cycles before ending the run loop.
Get/set the input filehandle.
Gives access to the internal OID tree, stored as a hash with the following structure:
oid_tree => {
FUNC_OID => [ FUNC_TYPE, FUNC_VALUE ],
...
}
where FUNC_OID is the absolute OID of the SNMP function, FUNC_TYPE the function type ("integer", "counter", "gauge", etc), and FUNC_VALUE the function value.
You should not directly modify this hash but instead use the appropriate methods for adding OID entries.
Get/set the output filehandle.
Get/set the refresh delay before calling the backend collect callback to update the OID tree.

...

SNMP::Persist is another pass_persist backend for writing Net-SNMP extensions, but relies on threads.
The documentation of Net-SNMP, especially the part on how to configure a pass or pass_persist extension:

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

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

You can find documentation for this module with the perldoc command.
perldoc SNMP::Extension::PassPersist
You can also look for information at:
http://rt.cpan.org/Dist/Display.html?Queue=SNMP-Extension-PassPersist

Copyright 2008 Sébastien Aperghis-Tramoni, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.