[SNMP4J] SNMP trap message parsing using SNMP4J APIs

Frank Fock fock at agentpp.com
Fri Aug 13 16:36:08 CEST 2010



Hi,

This might be a misunderstanding based on incorrect naming: The SNMP  
message contains the message header (i.e. the version) and the PDU  
(the payload of the message). With your approach you decode the PDU  
only although the byte array contains the message header too.

Best regards,
Frank

Am 13.08.2010 um 16:17 schrieb Murali Natarajan <murali.natarajan at jpmchase.com 
 >:

> I am not sure how to use the MPv1 model to receive V1Traps coming in  
> as byte[].
>
> On the other hand, I tried:
>
> byte[] trapArray = (byte[]) src; ('src' is the incoming SNMP message  
> payload passed in as 'Object')
> ByteBuffer pduBuffer = ByteBuffer.wrap(trapArray);
>
> PDUv1 pdu = new PDUv1();
>
> BERInputStream berStream = new BERInputStream(pduBuffer);
>
> Try {
>    pdu.decodeBER(berStream);
> } catch (IOException e) {
>    // TODO Auto-generated catch block
>    e.printStackTrace();
> }
>
> Getting an error as below:
>
> java.io.IOException: Unsupported PDU type: 48
>
>    at org.snmp4j.PDUv1.decodeBER(PDUv1.java:139)
>
> If I use another vendor tool such as iReasoning to use the same byte 
> [] and create their 'SNMPV1Trap' class, I am able to extract all of  
> the trap data nicely. That would mean byte[] has everything I need..
>
> Any suggestions?
>
> Murali Natarajan
> CIG TSS Admin Center Architecture
> 312-954-1670
> murali.natarajan at jpmchase.com
>
> -----Original Message-----
> From: Mackay, Scott [mailto:scott.mackay at progeny.net]
> Sent: Tuesday, August 10, 2010 12:33 PM
> To: Murali Natarajan
> Cc: snmp4j at agentpp.org
> Subject: RE: [SNMP4J] SNMP trap message parsing using SNMP4J APIs
>
>
> Have you looked at the MessageProcessingModel (and MPv3,MPv1,  
> MPv2c)?  There is a method prepareDataElements() which seems  
> responsible for converting streams into the SNMP4j classes though I  
> have not done that myself.
>
> -Scott
>
> -----Original Message-----
> From: Murali Natarajan [mailto:murali.natarajan at jpmchase.com]
> Sent: Tue 8/10/2010 1:20 PM
> To: Shlomo
> Cc: Mackay, Scott; snmp4j at agentpp.org
> Subject: RE: [SNMP4J] SNMP trap message parsing using SNMP4J APIs
>
> Nope.
>
> This part is being handled by another tool. It will receive the  
> incoming trap and return a byte []. That is my starting point 1) to  
> convert that into a trap object 2) extract details from there etc
>
> Murali Natarajan
> CIG TSS Admin Center Architecture
> 312-954-1670
> murali.natarajan at jpmchase.com<mailto:murali.natarajan at jpmchase.com>
>
> From: Shlomo [mailto:shlomo at tikalk.com]
> Sent: Tuesday, August 10, 2010 11:50 AM
> To: Murali Natarajan
> Cc: Mackay, Scott; snmp4j at agentpp.org
> Subject: Re: [SNMP4J] SNMP trap message parsing using SNMP4J APIs
>
> Hi,
> Is this what you need?
>
> public void processPdu(
> CommandResponderEvent e) {
>         logger.debug("processPdu start ...");
>         PDU command = e.getPDU();
>         if (command != null) {
>           System.out.println(command.toString());
>
> On Tue, Aug 10, 2010 at 7:40 PM, Murali Natarajan <murali.natarajan at jpmchase.com 
> <mailto:murali.natarajan at jpmchase.com>> wrote:
> Yes but in my case the difference is some other code (not the SNMP4J  
> listeners) is receiving the incoming trap as a byte array. So I need  
> to:
>
> 1. Convert this byte array to a trap object or a PDU; figure out  
> what version etc in doing that conversion
> 2. Extract information from the trap object.
>
> It is for the step 1, I am looking for APIs in SNMP4J.
>
> Thanks.
>
> Murali Natarajan
> CIG TSS Admin Center Architecture
> 312-954-1670
> murali.natarajan at jpmchase.com<mailto:murali.natarajan at jpmchase.com>
>
> -----Original Message-----
> From: Mackay, Scott [mailto:scott.mackay at progeny.net<mailto:scott.mackay at progeny.net 
> >]
> Sent: Tuesday, August 10, 2010 4:23 AM
> To: Murali Natarajan; snmp4j at agentpp.org<mailto:snmp4j at agentpp.org>
> Subject: RE: [SNMP4J] SNMP trap message parsing using SNMP4J APIs
>
>
> A good method is following the steps used in the SnmpRequest.java  
> from the source code.  The code is located in src/org/snmp4j/tools/ 
> console and is 1 file.  As a note, if you are in that directory you  
> can run the jarred version for comparison as: "java - 
> cp ../../../../../dist/snmp4j-1.10.2.jar org.snmp4j/tools/console/ 
> SnmpRequest"
> You will notice there is an option, -Ol, which will listen for traps  
> and such.  I would follow through the code on how that is set up,  
> waited on, and processed.
>
>
> -Scott
>
> -----Original Message-----
> From: snmp4j-bounces at agentpp.org<mailto:snmp4j-bounces at agentpp.org>  
> on behalf of Murali Natarajan
> Sent: Mon 8/9/2010 3:56 PM
> To: snmp4j at agentpp.org<mailto:snmp4j at agentpp.org>
> Subject: (nwl)  [SNMP4J] SNMP trap message parsing using SNMP4J APIs
>
> Hi,
>
> I have an SNMP trap message being received as a byte array by an ESB  
> tool. I am trying to understand how to parse and extract the trap  
> message details (OIDs, their values, etc) from this byte array -  
> using SNMP4J APIs.
>
> Is there a reference sample code available for this? If not, what  
> are the specific APIs to use etc?
>
> Murali Natarajan
> CIG TSS Admin Center Architecture
> 312-954-1670
> murali.natarajan@ 
> jpmchase.com< 
> mailto:murali.natarajan@ 
> jpmchase.com><mailto:murali.natarajan at jpmchase.com<mailto:murali.natarajan at jpmchase.com 
> >>
>
>
>
> This communication is for informational purposes only. It is not
> intended as an offer or solicitation for the purchase or sale of
> any financial instrument or as an official confirmation of any
> transaction. All market prices, data and other information are not
> warranted as to completeness or accuracy and are subject to change
> without notice. Any comments or statements made herein do not
> necessarily reflect those of JPMorgan Chase & Co., its subsidiaries
> and affiliates.
>
> This transmission may contain information that is privileged,
> confidential, legally privileged, and/or exempt from disclosure
> under applicable law. If you are not the intended recipient, you
> are hereby notified that any disclosure, copying, distribution, or
> use of the information contained herein (including any reliance
> thereon) is STRICTLY PROHIBITED. Although this transmission and any
> attachments are believed to be free of any virus or other defect
> that might affect any computer system into which it is received and
> opened, it is the responsibility of the recipient to ensure that it
> is virus free and no responsibility is accepted by JPMorgan Chase &
> Co., its subsidiaries and affiliates, as applicable, for any loss
> or damage arising in any way from its use. If you received this
> transmission in error, please immediately contact the sender and
> destroy the material in its entirety, whether in electronic or hard
> copy format. Thank you.
>
> Please refer to http://www.jpmorgan.com/pages/disclosures for
> disclosures relating to European legal entities.
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org<mailto:SNMP4J at agentpp.org>
> http://lists.agentpp.org/mailman/listinfo/snmp4j
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org<mailto:SNMP4J at agentpp.org>
> http://lists.agentpp.org/mailman/listinfo/snmp4j
>
>
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j



More information about the SNMP4J mailing list