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.

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 . " Mb +ps\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.

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::Tr +ap # $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->alarmInformati +on . "\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


In reply to Namespace question for new SNMP modules by ewaters

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.