[SNMP4J] Tables: createRow

Jerome Jabson jjabson at yahoo.com
Wed Oct 14 03:56:24 CEST 2009


Thanks again Frank.

Last question - I hope! I've change my code to look like the following:

        OID rowStatusOid = new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.9");
        OID indexOid = new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.1");

        VariableBinding[] rowVal = new VariableBinding[]{
                new VariableBinding(new OID ("1.3.6.1.4.1.9.9.42.1.2.1.1.2"), new Integer32(3)),
                new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.2"), new OctetString("Admin")),
                new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.3"), new OctetString("Admin Tag")),
                new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.4"), new Integer32(5)),
                new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.5"), new Integer32(5001)),
                new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.6"), new Integer32(65)),
                new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.7"), new Integer32(5001)),
                new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.8"), new Integer32(2)),
                new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.9"), new Integer32(1)),
                new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.10"), new Integer32(1)),
                new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.11"), new OctetString("Group1"))
        };
        
        
        responseEvent = tableUtils.createRow(target, rowStatusOid, indexOid, rowVal);
        System.out.println("CreatRow response: " + responseEvent.toString());

Do I need to set the Index to create the row? In this version of my code it did, and I also did it without. The reason I ask is that I keep getting this error:
errorStatus=Unable to create object(11)

I can't see to find what this error means. I was wondering if you could possible shed some light on this?

Thanks,
Jerome



----- Original Message ----
From: Frank Fock <fock at agentpp.com>
To: Jerome Jabson <jjabson at yahoo.com>
Cc: snmp4j at agentpp.org
Sent: Tue, October 13, 2009 2:29:57 PM
Subject: Re: [SNMP4J] Tables: createRow

Jerome,

It is as the error message indicates: Instead
Variable[] ...
you need to use
VariableBinding[]...

Thus, you need to specify the columnar object ID
for each column with each column value.
TableUtils will then take care to append the row index
to each column OID to set its value.

Regards,
Frank


Jerome Jabson wrote:
> Thanks Frank! I'm still having some problems trying to create a row. I have the code below:
> 
>         OID rowStatusOid = new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.9");
>         OID indexOid = new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.1");
>                 Variable[] rowValue = new Variable[]{
>             new OctetString("Admin"),
>             new OctetString("Admin Tag"),
>             new Integer32(5),
>             new Integer32(5001),
>             new Integer32(65),
>             new Integer32(5001),
>             new Integer32(2),
>             new Integer32(1),
>             new Integer32(1),
>             new OctetString("Group1")                };
>                 responseEvent = tableUtils.createRow(target, rowStatusOid, indexOid, (VariableBinding[]) rowValue);
>         System.out.println("CreatRow response: " + responseEvent.toString());
> 
> When createRow gets called I get the following error:
> java.lang.ClassCastException: [Lorg.snmp4j.smi.Variable; cannot be cast to [Lorg.snmp4j.smi.VariableBinding;
> 
> Am I calling this the right way? 
> Thanks again,
> Jerome
> 
> 
> 
> 
> ----- Original Message ----
> From: Frank Fock <fock at agentpp.com>
> To: Jerome Jabson <jjabson at yahoo.com>
> Cc: snmp4j at agentpp.org
> Sent: Tue, October 13, 2009 12:14:34 PM
> Subject: Re: [SNMP4J] Tables: createRow
> 
> Hello Jerome,
> 
> All TCs are directly based on SNMP base types (if not
> the MIB specification is buggy). Use that base type,
> because on the wire there are no TCs but base types
> only.
> 
> Best regards,
> Frank
> 
> Jerome Jabson wrote:
>> Hello,
>> 
>> I'm new to using SNMP4J. I'm writing a compliance test application, and wanted to use the SNMP4J APIs. I'm having some difficulties with trying to create a row, and have searched the forum for some examples. the Java docs for TableUtils createRow requires an array of VariableBinding values such as:
>> 
>> 
>> Variable[] rowValues = new Variable[] {
>>                     new Integer32(RowStatus.active),
>>                     new Integer32(rowCount),
>>                     new OctetString(remotePeer.cisIp),
>>                     new OctetString(remotePeer.uid),
>>                     new OctetString(remotePeer.admIp),
>>                     new Integer32(1),
>>                     new Integer32(1),
>>                     new Integer32(1),
>>                     new Integer32(1),
>>                     new OctetString()
>>                  };
>> 
>> My question is: How can I do this for types that are custom developed? i.e. We have TC type of RttmonRttType or other types
>> I can't seem to fined such ass SnmpAdminString, TruthValue, etc...
>> Is there someplace that shows me how I can accomplish this?
>> 
>> Thanks in advance,
>> Jerome
>> 
>> 
>>       _______________________________________________
>> SNMP4J mailing list
>> SNMP4J at agentpp.org
>> http://lists.agentpp.org/mailman/listinfo/snmp4j
> 
> -- AGENT++
> http://www.agentpp.com
> http://www.snmp4j.com
> http://www.mibexplorer.com
> http://www.mibdesigner.com
> 
> 
>      

-- AGENT++
http://www.agentpp.com
http://www.snmp4j.com
http://www.mibexplorer.com
http://www.mibdesigner.com


      



More information about the SNMP4J mailing list