[SNMP4J] i need help

Dawid daquer at poczta.neostrada.pl
Wed May 3 17:14:49 CEST 2006


Hello, here is some sample of using snmp.get
I suggest using try{}catch{} here
Greetings
Balt

Address targetAddress = GenericAddress.parse("udp:127.0.0.1/8001");
   CommunityTarget target = new CommunityTarget();
   target.setCommunity(new OctetString(SnmpConnection.community));
   target.setAddress(targetAddress);
   target.setTimeout(200);
   target.setRetries(2);

   //if(snmpVersion==2)
   target.setVersion(SnmpConstants.version2c);

   TransportMapping transport;
   transport= new DefaultUdpTransportMapping();
   transport.listen();
   snmp = new Snmp(transport);
   PDU pdu = new PDU();
   for(int i=0; i<list.size();i++){ //object binding
       pdu.add(new VariableBinding(new OID(list.getSnmpObject(i).mibId )));
   }
   pdu.setType(PDU.GET);
   ResponseEvent response = snmp.send(pdu, target);
   if(response==null) throw new IOException();
   VariableBinding[] variableB = response.getResponse().toArray();
   for(int i=0; i<list.size();i++){
    String tmp=variableB[i].getVariable().toString();
    System.out.println(tmp);
    list.getSnmpObject(i).value=tmp;
   }


----- Original Message ----- 
From: "pradeep kumar" <pradeepk at cdotb.ernet.in>
To: <snmp4j at agentpp.org>
Sent: Monday, May 01, 2006 12:47 PM
Subject: [SNMP4J] i need help


> hi frank,
>
> i am new to snmp, i want some example programs  that  use java snmp4j API
> s
> and  gives me the information like
> all the initial steps that are required to create an session object , PDU
> etc
> and how to use snmpget , snmpwalk in the java program  etc..using the
> snmp4j libraries...
>
> thanks
> pradeep
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
>





More information about the SNMP4J mailing list