Hi Chris,

Thanks for the advice. I am frankly a little surprised that this
functionality is not included in the Perl API, but I guess parsing the
text output from snmptrapd is also feasible, if a little more work.

(copying to list for archiving)
/Joel

On Thu, Dec 16, 2010 at 12:58 AM, Chris Bartram <chrisrbart...@yahoo.com> wrote:
> If you just need to parse/handle incoming SNMP traps, you merely need to
> write a perl script that parses the output of the snmptrapd process and
> invoke that script via a traphandle command in snmptrapd.conf.
>
> The format of the traps delivered to your handler isn't documented real
> well, but it's pretty easy to parse. Basically you get two header lines (you
> can chomp hostname and source ip address from those lines), then a series of
> input lines made up of OID ids and values - separated by the first space in
> the input line.
>
> Hope that helps. If you need further help let me know; I've written about a
> dozen handlers in perl in the past several weeks for various MIBs.
>
> -Chris Bartram
>
> "The purpose of life is not to be happy. It is to be useful, to be
> honorable, to be compassionate, to have it make some difference that you
> have lived and lived well". (Ralph Waldo Emerson)
>
> ________________________________
> From: Joel Hansell <joel.hans...@gmail.com>
> To: net-snmp-users@lists.sourceforge.net
> Sent: Wed, December 15, 2010 8:15:52 AM
> Subject: How can my perl script receive SNMP traps?
>
> Hi,
>
> I would like to do the following, but I'm not sure I'm using the best
> method:
>
> A perl script, running on a Sparc/Solaris 10 machine, should wait for
> incoming SNMP trap packets (on port 162 for instance). When it
> receives a trap, it should decode it and do some processing on it, and
> then resume waiting for the next trap.
>
> Am I correct in assuming that this cannot be done from within Perl
> with the net-snmp perl modules?
>
> I found some clues elsewhere that I should use the "snmptrapd" binary
> and use the embedded perl functions of it, to call my script when
> snmptrapd receives a message. This could work, but would be
> impractical since the embedded perl option requires a perl binary
> compiled without large file support. I do not own the target system
> and hence cannot replace the compiler/interpreter. I could ship my
> software with a specially-compiled perl, but that would give me
> cross-platform issues I was hoping to avoid.
>
> Best regards,
> Joel Hansell
>
> ------------------------------------------------------------------------------
> Lotusphere 2011
> Register now for Lotusphere 2011 and learn how
> to connect the dots, take your collaborative environment
> to the next level, and enter the era of Social Business.
> http://p.sf.net/sfu/lotusphere-d2d
> _______________________________________________
> Net-snmp-users mailing list
> Net-snmp-users@lists.sourceforge.net
> Please see the following page to unsubscribe or change other options:
> https://lists.sourceforge.net/lists/listinfo/net-snmp-users
>
>

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to