[SNMP4J] problem in using TableUtils class...
Frank Fock
fock at agentpp.com
Mon Jun 30 18:33:25 CEST 2008
Hi,
What is the status of the TableEvent object you get?
I guess it is an error state...
Best regards,
Frank
AMRUTH KUMAR JUTURU wrote:
> Hi all,
>
> I am trying to use TableUtils class to read the bgp routing
> table entries. But I have a problem....This is the code....
>
> /*
> * To change this template, choose Tools | Templates
> * and open the template in the editor.
> */
>
> package snmp;
>
> import java.io.IOException;
> import java.util.List;
> import java.util.Vector;
> import java.util.logging.Level;
> import java.util.logging.Logger;
> import org.snmp4j.CommunityTarget;
> import org.snmp4j.Snmp;
> import org.snmp4j.smi.OID;
> import org.snmp4j.smi.OctetString;
> import org.snmp4j.smi.VariableBinding;
> import org.snmp4j.transport.DefaultUdpTransportMapping;
> import org.snmp4j.util.TableEvent;
> import org.snmp4j.util.TableUtils;
>
> /**
> *
> * @author crysm
> */
> public class TableMain {
>
> public static void main(String args[])
> {
> try {
> TableReader tr = new TableReader();
> Snmp session = new Snmp(new DefaultUdpTransportMapping());
> CommunityTarget target = new CommunityTarget();
> target.setCommunity(new OctetString("public"));
> TableUtils tu = new TableUtils(session,tr);
> OID[] oidArray = new OID[14];
> oidArray[0] = new OID("1.3.6.1.2.1.15.6.1.1");
> oidArray[1] = new OID("1.3.6.1.2.1.15.6.1.2");
> oidArray[2] = new OID("1.3.6.1.2.1.15.6.1.3");
> oidArray[3] = new OID("1.3.6.1.2.1.15.6.1.4");
> oidArray[4] = new OID("1.3.6.1.2.1.15.6.1.5");
> oidArray[5] = new OID("1.3.6.1.2.1.15.6.1.6");
> oidArray[6] = new OID("1.3.6.1.2.1.15.6.1.7");
> oidArray[7] = new OID("1.3.6.1.2.1.15.6.1.8");
> oidArray[8] = new OID("1.3.6.1.2.1.15.6.1.9");
> oidArray[9] = new OID("1.3.6.1.2.1.15.6.1.10");
> oidArray[10] = new OID("1.3.6.1.2.1.15.6.1.11");
> oidArray[11] = new OID("1.3.6.1.2.1.15.6.1.12");
> oidArray[12] = new OID("1.3.6.1.2.1.15.6.1.13");
> oidArray[13] = new OID("1.3.6.1.2.1.15.6.1.14");
> List list = tu.getTable(target, oidArray,null,null);
> System.out.println("The size of the list is : "+ list.size());
> System.out.println(list.get(0).getClass());
> for(int i=0;i<list.size();i++)
> {
> TableEvent tableevent = (TableEvent)list.get(i);
> VariableBinding[] vb = tableevent.getColumns();
> if(vb==null)
> System.out.println("this is null....");
> // System.out.println("size of the vb is : "+vb.length);
> /* for(int j=0;j<vb.length;j++)
> {
> System.out.println(vb[j]);
> }*/
> }
>
>
> } catch (IOException ex) {
> Logger.getLogger(TableMain.class.getName()).log(Level.SEVERE,
> null, ex);
> }
> }
>
> }
>
>
>
> and the code for other class is..
>
> /*
> * To change this template, choose Tools | Templates
> * and open the template in the editor.
> */
>
> package snmp;
>
> import org.snmp4j.PDU;
> import org.snmp4j.Target;
> import org.snmp4j.util.PDUFactory;
>
> /**
> *
> * @author crysm
> */
> public class TableReader implements PDUFactory
> {
>
> public PDU createPDU(Target arg0) {
> PDU pdu = new PDU();
> return pdu;
> }
>
> }
>
>
> .... in the end...when I get the list of TableEvents with the help of
> getTable function of TableUtils class...the TableEvent.getColumns returns
> null.....Can you please help with this..Thanks in advance..
>
> This is the output I am getting....
>
> The size of the list is : 1
> class org.snmp4j.util.TableEvent
> this is null....
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com
More information about the SNMP4J
mailing list