[SNMP4J] snmpwalk
snmp girl
snmp.girl at gmail.com
Thu Apr 10 14:46:24 CEST 2008
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
More information about the SNMP4J
mailing list