[SNMP4J] How to create a trap pdu

Gian Marco Gallo gianmarco.gallo at elaide.com
Thu Jun 24 12:25:39 CEST 2010


  Hello guys

Here I am with another noob question. I want to send a trap message to a 
snmp server that contains the following structure values in his .mib file:

alarm OBJECT IDENTIFIER ::= {nms 1}
     alarmData OBJECT IDENTIFIER ::= {alarm 1}
     alarmTrap OBJECT IDENTIFIER ::= {alarm 2}

alarmId OBJECT-TYPE
         SYNTAX Integer32
         MAX-ACCESS read-only
         STATUS current
         DESCRIPTION "Alarm's identifier."
         ::= {alarmData 1}

     alarmValue OBJECT-TYPE
         SYNTAX DisplayString
         MAX-ACCESS read-only
         STATUS current
         DESCRIPTION "Alarm's value."
         ::= {alarmData 2}

openTrap NOTIFICATION-TYPE
         OBJECTS {alarmId, alarmValue}
         STATUS  current
         DESCRIPTION "New alarm opened."
         ::= {alarmTrap 1}

So I've created my PDU with this code:

pdu = new ScopedPDU();
pdu.setType(ScopedPDU.TRAP);
pdu.setContextName(new OctetString("CryptoExtWeb problem"));

But now I don't understand how I can insert the values required by the 
.mib file. Should I create and construct a new object or what?

Thanks for your help

-- 
Gian Marco Gallo
Elaide SRL

Email: gianmarco.gallo at elaide.com
Phone: +39 049 4102390




More information about the SNMP4J mailing list