[SNMP4J] snmpwalk

Frank Fock fock at agentpp.com
Fri Apr 11 01:10:48 CEST 2008


Hi,

You can use the TreeUtils class to implement a walk:
http://www.snmp4j.org/doc/org/snmp4j/util/TreeUtils.html

Best regards,
Frank

snmp girl wrote:
> Hi
> I wrote my first program using the snmp4j and it works , it is a basic
> program that used the snmpset aand snmpget (udp.get/udp.set)
> now I want to use the snmpwalk , and I don't if there is a function to use
> or I have to write a whole programm, because to access to the oid of the sql
> server mib I should use the snmpwalk that I had already test it in the mode
> console and it works.
> 
> this is my program:
> 
> 
> import org.snmp4j.*;
> import org.snmp4j.event.*;
> import org.snmp4j.smi.*;
> import org.snmp4j.transport.*;
> import java.io.*;
> import org.snmp4j.CommunityTarget;
> 
> public class Test
> {
>     public static void main(String[] args)throws IOException {
>         // TODO code application logic here
>         CommunityTarget target = new CommunityTarget();
>         Address targetaddress = new UdpAddress("127.0.0.1/161");
>         target.setAddress(targetaddress);
>         target.setCommunity(new OctetString("public"));
>         target.setTimeout (1000);
>         target.setVersion(0);
>         target.setRetries(1);
> 
>        PDU pdu = new PDU();
>        pdu.setType(PDU.GET);
>        pdu.add(new VariableBinding(new OID("1.3.6.1.2.1.1.1.0")));
>        TransportMapping transport = new DefaultUdpTransportMapping();
>        transport.listen();
>        try
>        {
>            Snmp snmp = new Snmp(transport);
>            ResponseEvent respEv = snmp.send(pdu, target);
>            PDU response = respEv.getResponse();
>            System.out.println(response);
>        }
>        catch (Exception e)
>        {
>            System.out.println("Errror in snmp");
>        }
>       }
> }
> thanks
> _______________________________________________
> 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