@Ignore @Test public void testSnmpSyncSetList() { SnmpSimpleSet.snmpSyncSetList(ip, "public", errorCount); SnmpSimpleGet.snmpSyncGetList(ip, "public", oids); }
public static void snmpSyncSetList(String ip, String community, String oidStr) { CommunityTarget target = createDefault(ip, community); Snmp snmp; try { DefaultUdpTransportMapping transport = new DefaultUdpTransportMapping(); snmp = new Snmp(transport); snmp.listen(); PDU pdu = new PDU(); pdu.add(new VariableBinding(new OID(oidStr), new Integer32(123))); pdu.setType(PDU.SET); ResponseEvent event = snmp.send(pdu, target, null); System.out.println("PeerAddress:" + event.getPeerAddress()); PDU response = event.getResponse(); if (response == null) { System.out.print("response is null, request time out" + NEXT_LINE); } else { System.out.println("response pdu size is " + response.size()); for (int i = 0; i < response.size(); i++) { VariableBinding vb = response.get(i); System.out.println(vb.getOid() + " = " + vb.getVariable()); } } System.out.println("SNMP GET one OID value finished !"); snmp.close(); } catch (Exception e) { throw new RuntimeException(e); } }
SnmpSimpleSet { public static void snmpSyncSetList(String ip, String community, String oidStr) { CommunityTarget target = createDefault(ip, community); Snmp snmp; try { DefaultUdpTransportMapping transport = new DefaultUdpTransportMapping(); snmp = new Snmp(transport); snmp.listen(); PDU pdu = new PDU(); pdu.add(new VariableBinding(new OID(oidStr), new Integer32(123))); pdu.setType(PDU.SET); ResponseEvent event = snmp.send(pdu, target, null); System.out.println("PeerAddress:" + event.getPeerAddress()); PDU response = event.getResponse(); if (response == null) { System.out.print("response is null, request time out" + NEXT_LINE); } else { System.out.println("response pdu size is " + response.size()); for (int i = 0; i < response.size(); i++) { VariableBinding vb = response.get(i); System.out.println(vb.getOid() + " = " + vb.getVariable()); } } System.out.println("SNMP GET one OID value finished !"); snmp.close(); } catch (Exception e) { throw new RuntimeException(e); } } }
SnmpSimpleSet { public static void snmpSyncSetList(String ip, String community, String oidStr) { CommunityTarget target = createDefault(ip, community); Snmp snmp; try { DefaultUdpTransportMapping transport = new DefaultUdpTransportMapping(); snmp = new Snmp(transport); snmp.listen(); PDU pdu = new PDU(); pdu.add(new VariableBinding(new OID(oidStr), new Integer32(123))); pdu.setType(PDU.SET); ResponseEvent event = snmp.send(pdu, target, null); System.out.println("PeerAddress:" + event.getPeerAddress()); PDU response = event.getResponse(); if (response == null) { System.out.print("response is null, request time out" + NEXT_LINE); } else { System.out.println("response pdu size is " + response.size()); for (int i = 0; i < response.size(); i++) { VariableBinding vb = response.get(i); System.out.println(vb.getOid() + " = " + vb.getVariable()); } } System.out.println("SNMP GET one OID value finished !"); snmp.close(); } catch (Exception e) { throw new RuntimeException(e); } }  }
SnmpSimpleSet { public static void snmpSyncSetList(String ip, String community, String oidStr) { CommunityTarget target = createDefault(ip, community); Snmp snmp; try { DefaultUdpTransportMapping transport = new DefaultUdpTransportMapping(); snmp = new Snmp(transport); snmp.listen(); PDU pdu = new PDU(); pdu.add(new VariableBinding(new OID(oidStr), new Integer32(123))); pdu.setType(PDU.SET); ResponseEvent event = snmp.send(pdu, target, null); System.out.println("PeerAddress:" + event.getPeerAddress()); PDU response = event.getResponse(); if (response == null) { System.out.print("response is null, request time out" + NEXT_LINE); } else { System.out.println("response pdu size is " + response.size()); for (int i = 0; i < response.size(); i++) { VariableBinding vb = response.get(i); System.out.println(vb.getOid() + " = " + vb.getVariable()); } } System.out.println("SNMP GET one OID value finished !"); snmp.close(); } catch (Exception e) { throw new RuntimeException(e); } }  static void snmpSyncSetList(String ip, String community, String oidStr); }
SnmpSimpleSet { public static void snmpSyncSetList(String ip, String community, String oidStr) { CommunityTarget target = createDefault(ip, community); Snmp snmp; try { DefaultUdpTransportMapping transport = new DefaultUdpTransportMapping(); snmp = new Snmp(transport); snmp.listen(); PDU pdu = new PDU(); pdu.add(new VariableBinding(new OID(oidStr), new Integer32(123))); pdu.setType(PDU.SET); ResponseEvent event = snmp.send(pdu, target, null); System.out.println("PeerAddress:" + event.getPeerAddress()); PDU response = event.getResponse(); if (response == null) { System.out.print("response is null, request time out" + NEXT_LINE); } else { System.out.println("response pdu size is " + response.size()); for (int i = 0; i < response.size(); i++) { VariableBinding vb = response.get(i); System.out.println(vb.getOid() + " = " + vb.getVariable()); } } System.out.println("SNMP GET one OID value finished !"); snmp.close(); } catch (Exception e) { throw new RuntimeException(e); } }  static void snmpSyncSetList(String ip, String community, String oidStr);  }