[SNMP4J] Tables: createRow

Frank Fock fock at agentpp.com
Thu Oct 15 00:07:14 CEST 2009


Hi Jerome,

Just use
OID indexOID = new OID("1");
That should do the trick.

Best regards,
Frank

Jerome Jabson wrote:
> Hi Frank,
> 
> This is really strange. The response from the table create looks likes it's appending the OID as an Index.
> When I do a get on the table I am trying to create a row it seems to work fine:
> 
> [org.snmp4j.util.TableEvent[index=1,vbs=
> [null, 1.3.6.1.4.1.9.9.42.1.2.1.1.2.1 = , 
> 1.3.6.1.4.1.9.9.42.1.2.1.1.3.1 = , 
> 1.3.6.1.4.1.9.9.42.1.2.1.1.4.1 = 1, 
> 1.3.6.1.4.1.9.9.42.1.2.1.1.5.1 = 5000, 
> 1.3.6.1.4.1.9.9.42.1.2.1.1.6.1 = 60, 
> 1.3.6.1.4.1.9.9.42.1.2.1.1.7.1 = 5000, 
> 1.3.6.1.4.1.9.9.42.1.2.1.1.8.1 = 2, 
> 1.3.6.1.4.1.9.9.42.1.2.1.1.9.1 = 1, 
> 1.3.6.1.4.1.9.9.42.1.2.1.1.10.1 = 1, 
> 1.3.6.1.4.1.9.9.42.1.2.1.1.11.1 = ],
> status=0,exception=null,report=null]]
> 
> I am just modifying some of these values to see if the create row works. I'm just wondering when i specify 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");
> 
> Is there something I need to do besides what I have defined here? For all intensive purposes, I think I have this coded correctly:
> 
>         VariableBinding[] rowVal = new VariableBinding[]{
>                 new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.2"), new OctetString("")),
>                 new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.3"), new OctetString("")),
>                 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.10"), new Integer32(1)),
>                 new VariableBinding(new OID("1.3.6.1.4.1.9.9.42.1.2.1.1.11"), new OctetString(""))
>         };
>                 
>         responseEvent = tableUtils.createRow(target, rowStatusOid, indexOid, rowVal);
>         System.out.println("CreatRow response: " + responseEvent.toString());
> 
> The response below clearly shows that the OIDs are shown twice in the response, hence the too long indexes you are stating. 
> Is there some example you can point me to, so that I can see what I am doing wrong?
> 
> Thanks in advance,
> Jerome
> 
> 
> 
> 
> ----- Original Message ----
> From: Frank Fock <fock at agentpp.com>
> To: Jerome Jabson <jjabson at yahoo.com>
> Cc: snmp4j at agentpp.org
> Sent: Wed, October 14, 2009 11:29:05 AM
> Subject: Re: [SNMP4J] Tables: createRow
> 
> Jerome,
> 
> Your index value is a lot too long, I guess.
> The index value apparently is not a row index at all.
> 
> Best regards,
> Frank
> 
> Jerome Jabson wrote:
>> Hi Frank,
>>
>> Thanks for the response.
>>
>> Sorry I'm still having some trouble creating this row. Here is the response I get:
>>
>> RESPONSE[requestID=928478646, errorStatus=Unable to create object(11), errorIndex=1, VBS
>> [1.3.6.1.4.1.9.9.42.1.2.1.1.9.1.3.6.1.4.1.9.9.42.1.2.1.1.1 = 4;    <==== This is the rowStatus - I noticed it's set to 4 (CreateAndGo) this is automatically set 
>> 1.3.6.1.4.1.9.9.42.1.2.1.1.2.1.3.6.1.4.1.9.9.42.1.2.1.1.1 = Admin; <===== Is this the Index error as stated by #1??
>> 1.3.6.1.4.1.9.9.42.1.2.1.1.3.1.3.6.1.4.1.9.9.42.1.2.1.1.1 = Admin Tag; 
>> 1.3.6.1.4.1.9.9.42.1.2.1.1.4.1.3.6.1.4.1.9.9.42.1.2.1.1.1 = 5; 
>> 1.3.6.1.4.1.9.9.42.1.2.1.1.5.1.3.6.1.4.1.9.9.42.1.2.1.1.1 = 5001;
>>  1.3.6.1.4.1.9.9.42.1.2.1.1.6.1.3.6.1.4.1.9.9.42.1.2.1.1.1 = 65; 
>> 1.3.6.1.4.1.9.9.42.1.2.1.1.7.1.3.6.1.4.1.9.9.42.1.2.1.1.1 = 5001; 
>> 1.3.6.1.4.1.9.9.42.1.2.1.1.8.1.3.6.1.4.1.9.9.42.1.2.1.1.1 = 2; 
>> 1.3.6.1.4.1.9.9.42.1.2.1.1.10.1.3.6.1.4.1.9.9.42.1.2.1.1.1 = 1; 
>> 1.3.6.1.4.1.9.9.42.1.2.1.1.11.1.3.6.1.4.1.9.9.42.1.2.1.1.1 = Group1]]
>>
>> As you indicated I did not set the rowStatus. I'm wondering about the error above, Is the index automatically set by the createRow API?
>>
>> Thanks,
>> Jerome
>>
>>
>>
>> ----- Original Message ----
>> From: Frank Fock <fock at agentpp.com>
>> To: Jerome Jabson <jjabson at yahoo.com>
>> Cc: snmp4j at agentpp.org
>> Sent: Wed, October 14, 2009 12:01:56 AM
>> Subject: Re: [SNMP4J] Tables: createRow
>>
>> You should not include the RowStatus column in the value list,
>> particularly not if you specify a value (here 1) that cannot
>> be set during row creation.
>> The agent also returns the error index (the VB index starting
>> with 1). This indicates which of the VBs caused the error.
>>
>> Regards,
>> Frank
>>
>> Jerome Jabson wrote:
>>> 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
>>>
>>>
>>>      
> 

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




More information about the SNMP4J mailing list