Skip Menu |

This queue is for tickets about the Net-SNMPTrapd CPAN distribution.

Report information
The Basics
Id: 87610
Status: resolved
Worked: 3 hours (180 min)
Priority: 0/
Queue: Net-SNMPTrapd

People
Owner: VINSWORLD [...] cpan.org
Requestors: Roger.Soloy [...] telenor.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.12



CC: <Ole-Bjorn.Hessen [...] telenor.com>
Subject: Please accept the following simple patch for Net-SNMPTrapd
Date: Mon, 5 Aug 2013 07:17:39 +0000
To: <bug-Net-SNMPTrapd [...] rt.cpan.org>
From: <Roger.Soloy [...] telenor.com>
Two minor adjustments has been done to the Net-SNMPTrapd module: 1) Performance optimization: On high-volume trap receive it is costly to do a select and recv when a simple recv is enough. It means packet loss. The following patch only run select if Timeout is set. If not then blocking recv is called directly. $ diff -u /local/nms/perl/prod/lib/site_perl/5.16.0/Net/SNMPTrapd.pm /tmp --- /local/nms/perl/prod/lib/site_perl/5.16.0/Net/SNMPTrapd.pm 2013-08-02 17:30:25.000000000 +0200 +++ /tmp/SNMPTrapd.pm 2013-08-02 18:09:13.000000000 +0200 @@ -162,28 +162,27 @@ my $udpserver = $self->{'_UDPSERVER_'}; my $datagram; - # vars for IO select - my ($rin, $rout, $ein, $eout) = ('', '', '', ''); - vec($rin, fileno($udpserver), 1) = 1; - - # check if a message is waiting - if (select($rout=$rin, undef, $eout=$ein, $Timeout)) { - # read the message - if ($udpserver->recv($datagram, $datagramsize)) { - - $trap->{'_TRAP_'}{'PeerPort'} = $udpserver->SUPER::peerport; - $trap->{'_TRAP_'}{'PeerAddr'} = $udpserver->SUPER::peerhost; - $trap->{'_TRAP_'}{'datagram'} = $datagram; + if ($Timeout != 0) { + # vars for IO select + my ($rin, $rout, $ein, $eout) = ('', '', '', ''); + vec($rin, fileno($udpserver), 1) = 1; + + # check if a message is waiting + if (! select($rout=$rin, undef, $eout=$ein, $Timeout)) { + $LASTERROR = "Timed out waiting for datagram"; + return(0) + } + } - return bless $trap, $class - } else { - $LASTERROR = sprintf "Socket RECV error: $!"; - return(undef) - } - } else { - $LASTERROR = "Timed out waiting for datagram"; - return(0) + # read the message + if ($udpserver->recv($datagram, $datagramsize)) { + $trap->{'_TRAP_'}{'PeerPort'} = $udpserver->SUPER::peerport; + $trap->{'_TRAP_'}{'PeerAddr'} = $udpserver->SUPER::peerhost; + $trap->{'_TRAP_'}{'datagram'} = $datagram; + return bless $trap, $class } + $LASTERROR = sprintf "Socket RECV error: $!"; + return(undef) } 2) We got a snmp trap with a Null value from one of our vendor hosts that Net::SNMPTrapd dropped because it didn't parse NULL. Can you please update Net/SNMPTrapd.pm with a val_Null? ### Process varbinds my $trap2; $asn->prepare(" varbind SEQUENCE OF SEQUENCE { oid OBJECT IDENTIFIER, choice CHOICE { val_integer INTEGER, val_string STRING, val_OID OBJECT IDENTIFIER, val_IpAddr [APPLICATION 0] STRING, val_Counter32 [APPLICATION 1] INTEGER, val_Guage32 [APPLICATION 2] INTEGER, val_TimeTicks [APPLICATION 3] INTEGER, val_Opaque [APPLICATION 4] STRING, val_Counter64 [APPLICATION 6] INTEGER, val_Null NULL } } "); $ diff -u /local/nms/perl/prod/lib/site_perl/5.16.0/Net/SNMPTrapd.pm /tmp --- /local/nms/perl/prod/lib/site_perl/5.16.0/Net/SNMPTrapd.pm 2012-09-26 13:19:07.000000000 +0200 +++ /tmp/SNMPTrapd.pm 2013-08-02 17:17:58.000000000 +0200 @@ -269,7 +269,8 @@ val_Guage32 [APPLICATION 2] INTEGER, val_TimeTicks [APPLICATION 3] INTEGER, val_Opaque [APPLICATION 4] STRING, - val_Counter64 [APPLICATION 6] INTEGER + val_Counter64 [APPLICATION 6] INTEGER, + val_Null NULL } } "); Kind regards, Roger Soløy Solution Architect IP NMS/Technology/Telenor Norway

Message body is not shown because it is too large.

Sent email direct to: Roger.Soloy@telenor.com ---- Give this temporary release a try. I incorporated both recommendations, although the second one I did a bit differently to align with a greater change I had pending for the next release. ---- ATTACHMENT: Net-SNMPTrapd-0.11_1.tar.gz Waiting on feedback for the interim version and will go from there.
Subject: RE: [rt.cpan.org #87610] Please accept the following simple patch for Net-SNMPTrapd
Date: Thu, 15 Aug 2013 07:30:50 +0000
To: <bug-Net-SNMPTrapd [...] rt.cpan.org>
From: <Roger.Soloy [...] telenor.com>
Hi Michael, Sorry for not coming back to you earlier. However I have tested this release for about a week, and so far everything looks fine! Thanks a lot for your quick fix! Roger Show quoted text
-----Original Message----- From: Michael Vincent via RT [mailto:bug-Net-SNMPTrapd@rt.cpan.org] Sent: 7. august 2013 18:05 To: Soløy Roger Subject: [rt.cpan.org #87610] Please accept the following simple patch for Net-SNMPTrapd <URL: https://rt.cpan.org/Ticket/Display.html?id=87610 > Sent email direct to: Roger.Soloy@telenor.com ---- Give this temporary release a try. I incorporated both recommendations, although the second one I did a bit differently to align with a greater change I had pending for the next release. ---- ATTACHMENT: Net-SNMPTrapd-0.11_1.tar.gz Waiting on feedback for the interim version and will go from there.
RT-Send-CC: Roger.Soloy [...] telenor.com
Roger, I appreciate the thorough testing - more than my simple testing allows for. Question: I noticed when I now process a NULL trap, a value is still assigned to the OID, for example: OID->Type->Value .1.3.6.1.4.1.5000.1->NULL->1 Instead of default assigning '1', would it make sense to assign the text "(NULL)"? For example: OID->Type->Value .1.3.6.1.4.1.5000.1->NULL->(NULL) There has to be a value assigned so you don't get an undefined value print warning, just what to assign? I don't have a NULL trap generator, so have been trying with Net::SNMP - I wonder what your take is as you're seeing NULL traps in your testbed. Once that is answered, I have a few minor updates to the bin scripts and I'll publish official version 0.12 on CPAN. cheers. On Thu Aug 15 03:31:10 2013, Roger.Soloy@telenor.com wrote: Show quoted text
> Hi Michael, > > Sorry for not coming back to you earlier. However I have tested this > release for about a week, and so far everything looks fine! Thanks a > lot for your quick fix! > > Roger > > > > -----Original Message----- > From: Michael Vincent via RT [mailto:bug-Net-SNMPTrapd@rt.cpan.org] > Sent: 7. august 2013 18:05 > To: Soløy Roger > Subject: [rt.cpan.org #87610] Please accept the following simple patch > for Net-SNMPTrapd > > <URL: https://rt.cpan.org/Ticket/Display.html?id=87610 > > > Sent email direct to: Roger.Soloy@telenor.com > > ---- > Give this temporary release a try. I incorporated both > recommendations, although the second one I did a bit differently to > align with a greater change I had pending for the next release. > ---- > > ATTACHMENT: Net-SNMPTrapd-0.11_1.tar.gz > > Waiting on feedback for the interim version and will go from there.
Fixes included in new CPAN release 0.12 uploaded 16 AUG 2013, 12p EDT.
Patched in 0.12