What happens is that when I try to translate the information in the form of Response Event to String I get an exception, I think it's in this method, maybe I'm ignoring something, it's a new class for me, so I do not know it very well; this is the code of the methods that eclipse shows me:
//metodo traducir
public String traducirOid (OID oid) throws IOException
{
ResponseEvent event = obtenerOID(new OID[] { oid });
return event.getResponse().get(0).getVariable().toString();
}
and
public void actionPerformed(ActionEvent e)
{
try
{
segmentosIN = principal.traducirOid(new OID(principal.OIDin));
segmentosOUT = principal.traducirOid(new OID(principal.OIDout));
cuadrotexto.append("segmentos recibidos: " + segmentosIN + "\n" + "segmentos enviados: " + segmentosOUT);
} catch (IOException e1) {
e1.printStackTrace();
}
These are the other methods implemented:
public ResponseEvent obtenerOID(OID oids[]) throws IOException
{
PDU pdu = new PDU();
for (OID oid : oids) {
pdu.add(new VariableBinding(oid));
}
pdu.setType(PDU.GET);
ResponseEvent event = snmp.send(pdu, ObtenerTarget(), null);
if(event != null) {
return event;
}
throw new RuntimeException("GET timed out");
}
private Target ObtenerTarget() {
Address targetAddress = GenericAddress.parse(address);
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString("Redes20182-ganadores"));
target.setAddress(targetAddress);
target.setRetries(2);
target.setTimeout(1500);
target.setVersion(SnmpConstants.version2c);
return target;
}
I'm trying to translate an OID that shows me the TCP segments sent and received every so often ...
I hope you can help me. Greetings and thanks anything.