Hi

Yeah, I've solved that problem but now I'm not sure I'm going in the 
right direction. In fact my code is:


     private PDU pdu;
     private Snmp snmp;
     private VariableBinding oid;
     private VariableBinding mib_method;
     private VariableBinding object;
     private VariableBinding status;

     oid = new VariableBinding();
     oid.setOid(SnmpConstants.snmpTrapOID);
     oid.setVariable(new OID());
     mib_method = new VariableBinding();
     mib_method.setOid(new OID("0"));
     mib_method.setVariable(new 
OctetString("UCD-NOTIFICATION-TEST-MIB::demoNotif"));
     object = new VariableBinding();
     object.setOid(new OID("0"));
     object.setVariable(new OctetString("SNMPv2-MIB::sysLocation.0"));
     status = new VariableBinding();
     status.setOid(new OID("0"));
     status.setVariable(new OctetString("Test da codice"));

     pdu = new PDU();
     pdu.setType(PDU.TRAP);
     pdu.add(oid);
     pdu.add(mib_method);
     pdu.add(object);
     pdu.add(status);

The server log shows this:

Jun 30 09:50:13 qa1 snmptrapd[10477]: 2010-06-30 09:50:13 
luna.elaide.com [UDP: [192.168.5.19]:58057]: SNMPv2-MIB::snmpTrapOID.0 = 
OID: SNMPv2-SMI::zeroDotZero SNMPv2-SMI::zeroDotZero = STRING: 
"UCD-NOTIFICATION-TEST-MIB::demoNotif"        SNMPv2-SMI::zeroDotZero = 
STRING: "SNMPv2-MIB::sysLocation.0"   SNMPv2-SMI::zeroDotZero = STRING: 
"Test da codice"

Now I'm thinking that with the code I'm not able to 'hit' the right mib...

Thanks in advance


Il 29/06/2010 19:12, Frank Fock ha scritto:
> Hi,
>
> Object identifiers are specified in dotted notation:
> each sub-identifier separated by a dot ('.').
> For example: 1.3.6.1.4.1
>
> Best regards,
> Frank
>
>
> On 29.06.2010 12:39, Gian Marco Gallo wrote:
>>     Good day
>>
>> I'm trying to send a notification with snmp4j and to add informations in
>> my pdu (so the mib in the server can print the right message in the
>> server log). So I've tried this:
>>
>>
>>            pdu = new PDU();
>>            pdu.setType(PDU.TRAP);
>>            pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, new
>> OctetString("UCD-NOTIFICATION-TEST-MIB::demoNotif")));
>>
>> But in the server log appears this:
>>
>> Jun 29 12:30:14 qa1 snmptrapd[6166]: 2010-06-29 12:30:14 luna.elaide.com
>> [UDP: [192.168.5.19]:48917]: SNMPv2-MIB::snmpTrapOID.0 = Wrong Type
>> (should be OBJECT IDENTIFIER): STRING:
>> "UCD-NOTIFICATION-TEST-MIB::demoNotif"
>>
>> Any idea on how send an object identifier?
>> This is the mib on the server:
>>
>> UCD-NOTIFICATION-TEST-MIB DEFINITIONS ::= BEGIN
>>           IMPORTS ucdExperimental FROM UCD-SNMP-MIB;
>>
>>     ucdNotificationTestMib MODULE-IDENTITY
>>
>>
>>     demotraps  OBJECT IDENTIFIER ::= { ucdExperimental 990 }
>>     demonotifs OBJECT IDENTIFIER ::= { demotraps 0 }
>>
>>     *demoNotif*  NOTIFICATION-TYPE
>>           OBJECTS { sysLocation }
>>           STATUS current
>>           DESCRIPTION "An example of an SMIv2 notification"
>>           *::= { demonotifs 18 }*
>>
>>     ucdNotificationGroup NOTIFICATION-GROUP
>>
>>     END
>>
>> Thanks in advance
>>
>>


-- 
Gian Marco Gallo
Elaide SRL

Email: gianmarco.ga...@elaide.com
Phone: +39 049 4102390

_______________________________________________
SNMP4J mailing list
SNMP4J@agentpp.org
http://lists.agentpp.org/mailman/listinfo/snmp4j

Reply via email to