Ask a Question related to PERL Modules, Design and Development.
-
Eric Waters #1
Namespace question for new SNMP modules
I'm currently working on releasing a new distribution which I'm calling
Class::SNMP. As this is my first release to CPAN, I'm a bit apprehensive
about some of the coding decisions I've made, and hope that I'll get some
feedback after people look at what I've written. Firstly, though, I was
hoping to get some namespace advice.
With Class::SNMP, you can easily create your own class of an SNMP device
which you need to get and set values on, and trap traps from. From my POD:
package My::SNMPDevice;
use base 'Class::SNMP';
__PACKAGE__->MakeMethods(
mib => 'My-Custom-Device-MIB',
mib_root => 'mycustomdevice',
);
package main;
use My::SNMPDevice;
my $device = My::SNMPDevice->new(
hostname => '192.168.1.25'
);
print "Has a " . $device->Uptime . " uptime\n";
print "Port 4 is at speed " . $device->Ports->Entry(4)->Speed . " Mbps\n";
That's all fine and straight forward, and I feel confident that
Class::SNMP is the appropriate place for this. However, when I get into
traps, it gets more vague.
For trap handling, I would like a way to represent a trap as something a
bit more structured than a hashref. I've created a module SNMP::Trap
which is a simple trap object with accessors (thanks to Class::Accessor)
with object creation from a raw UDP trap packet (thanks to
Mon::SNMP) or the output of snmptrapd. Is it appropriate for this to be
SNMP::Trap? Or should it be Net::SNMP::Trap? Or something else? And
should I release it into a different distribution since it's out of the
Class::SNMP namespace?
This trap object I then will pass to a wrapper into a user-specific class
for dispatching. See this example code:
use SNMP::Trap;
use My::SNMPDevice; # A subclass of Class::SNMP
my $trap = SNMP::Trap->parse_snmptrapd_from_stdin();
my $obj_trap = My::SNMPDevice->parse_trap($trap); # expects SNMP::Trap
# $obj_trap isa Class::SNMP::Trap + My::SNMPDevice::Trap::<name>
my $success = $obj_trap->dispatch({
alarmWarning => sub { 1 };
_namer => 'trap_%s',
_default => \&trap_unhandled,
});
if (! $success) {
print "Couldn't dispatch for trap:\n" . $obj_trap->describe;
}
sub trap_alarmCritical {
my ($trap) = @_;
print $trap->hostname . " is critical: " . $trap->alarmInformation . "\n";
}
So, is SNMP::Trap appropriate?
Additionally, in classic feature-creep programming style, I now am wanting
to implement a Perl-based SNMP trap daemon since auto method generation
code is slow and therefore using trap dispatch from snmptrapd.conf
would be too slow. So, I'm thinking Net::Server::SNMP, but it wouldn't be
a full SNMP server, just the a trapd, so would Net::Server::SNMP::Trap be
more appropriate? Or Net::SNMP::Server::Trap? This would use the
SNMP::Trap objects (above) as the basis for trap handling and dispatch,
and would also seemingly need to be in a different distribution.
One last question (I know, I have a lot). I've identified a bug or two in
SNMP::Mib::Compiler (which I use heavily) and a needed extra feature to
Convert::BER. These modules haven't been updated lately, and I was
worried that I'll try and get patches to the maintainers and they won't
be reachable. If a module is 5+ years old and the maintainer is not
reachable (this is just hypothetical at this point), what's the protocol
to handle updating the code?
Thanks in advance! Sorry for the long post.
Eric Waters
Eric Waters Guest
-
Namespace for apartment threading modules ?
Looking for namespace advice... After building a specialized set of classes to support apartment threading of DBI... -
Installation problem - Net-SNMP Perl Modules on cygwin
When Net-SNMP Perl modules are installed in cygwin $cd net-snmp5.2.1/perl $perl MakeFile.PL Writing Makefile for NetSNMP::default_store... -
please help deciding on a namespace for a couple of modules
Hi, I'm currently writing a couple of modules that I want to release on CPAN. One is an object oriented generic framework for alternate move... -
RFC: Profusion of CPAN OO modules, Class:: namespace, how to fit in?
I have some additional OO helper modules to contribute to CPAN but with the profusion of OO modules, particularly under the Class:: namespace, I'd... -
little question about snmp
in /usr/tmp/snmpd.log ..... 06/22/03 18:44:51 EXCEPTIONS: authentication error: invalid community name: xyz 06/25/03 18:43:08 EXCEPTIONS:...



Reply With Quote

