title: How can my perl script receive SNMP traps from a managed system?
body: <p>I would like to do the following, but I'm not sure I'm using the best method:</p>
  
  <p>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.</p>
  
  <p>I've looked into Net::SNMP by David M. Town, but I think it only allows sending requests and receiving responses. I can't find a method to wait for spontaneous trap messages in this documentation:
  <a href="http://search.cpan.org/dist/Net-SNMP/lib/Net/SNMP.pm" rel="nofollow">http://search.cpan.org/dist/Net-SNMP/lib/Net/SNMP.pm</a></p>
  
  <p>The Net-SNMP package, on the other hand, seems like a very robust and well-used library, but even there the documentation does not provide me with a clear path. SNMP::TrapSession allows me to send traps, but not receive them (?).</p>
  
  <p>Some googling leads me to suggestiongs 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.</p>
  
  <p>The reason I'm using Perl and not Java with SNMP4J or similar, is that I have legacy perl code which has previously depended on HP NNM's perl API, and I need to move to a free software back-end to eliminate the license cost.</p>