I've been assigned a task to create a perl script that will receive SNMP traps (I'm quite new to SNMP) and insert certain values to a database in real time.I was advised to make a listener program myself, so that I don't have to take time reading the traps from logs(with snmptrapd), and instead process the traps immediately upon reciept.
To start off, I've tried out the code provided to Receiving traps in Simon Leinen's Site.(http://ftp.debian.org/doc/libsnmp-session-perl/snmp-session.html) I've been sending a dummy SNMPV2 trap to the script but it prompts "Can't call method "decode_trap_request" on an undefined value at recivtrap.pl" I am not sure if I am doing something wrong, I've placed this on the code:
if (defined($trap))
{
print "RECIVED TRAP\n";
my ($community, $enterprise, $agent,$generic, $specific, $sy
+sUptime, $bindings) = $session->decode_trap_request ($trap) or die "c
+annot decode trap received";
}
My program prints out "Recieved Trap" so that means $trap is defined, so I don't understand why the error "Can't call method "decode_trap_request" on an undefined value at recivtrap.pl" pops out whenever the program receives the trap.
The traps that I'm sending works with SNMPTRAPD perfectly (it shows me the traps that I've received). I'm sending V2 traps.
I've been stuck at this for quite a few days now, and I've emailed Mr. Leinen himself, but he might be too busy (and I misspelled his name in my email to him..forgive me) somebody here might have the answers to my question already. Thanks in advance :)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.