/** * Construct the PDU to perform the SNMP Get request and returns * the result in order to create the flow file. * @return {@link ResponseEvent} */ public ResponseEvent get() { try { PDU pdu = null; if(this.target.getVersion() == SnmpConstants.version3) { pdu = new ScopedPDU(); } else { pdu = new PDU(); } pdu.add(new VariableBinding(this.oid)); pdu.setType(PDU.GET); return this.snmp.get(pdu, this.target); } catch (IOException e) { logger.error("Failed to get information from SNMP agent; " + this, e); throw new ProcessException(e); } }
public ResponseEvent get(PDU pdu, Target target) { try { return snmp.get(pdu, target); } catch (IOException e) { e.printStackTrace(); } return null; }
/** * Sends a SET-type PDU to the target specified by the constructor. * * @param pdu * The message content to be sent to the target * @return ResponseEvent * @throws IOException */ public ResponseEvent get(PDU pdu, Snmp snmpob, UserTarget targetob, Boolean keepOpen) throws IOException { // Ensure the object has been instantiated if (!ready) { throw new IOException("Tried to send PDU before SNMP sending service is ready."); } // Start listening on UDP if (!listening) { startListen(); } // Try to send the SNMP request (synchronously) ResponseEvent responseEvent = null; try { responseEvent = snmpob.get(pdu, targetob); if (!keepOpen) { snmpob.close(); } } catch (IOException e) { throw new IOException("Failed to send SNMP request: " + e); } return responseEvent; }
/** * Construct the PDU to perform the SNMP Get request and returns * the result in order to create the flow file. * @return {@link ResponseEvent} */ public ResponseEvent get() { try { PDU pdu = null; if(this.target.getVersion() == SnmpConstants.version3) { pdu = new ScopedPDU(); } else { pdu = new PDU(); } pdu.add(new VariableBinding(this.oid)); pdu.setType(PDU.GET); return this.snmp.get(pdu, this.target); } catch (IOException e) { logger.error("Failed to get information from SNMP agent; " + this, e); throw new ProcessException(e); } }
pdu.setType(PDU.GET); snmp = new Snmp(transport); response = snmp.get(pdu, comtarget); if (response != null) { if (response.getResponse().getErrorStatusText().equalsIgnoreCase("Success")) {
pdu.add(new VariableBinding(levelOID)); pdu.add(new VariableBinding(effLevelOID)); response = snmp.get(pdu, target); PDU respPDU = response.getResponse(); if ((respPDU != null) &&
pdu.add(new VariableBinding(levelOID)); pdu.add(new VariableBinding(effLevelOID)); response = snmp.get(pdu, target); PDU respPDU = response.getResponse(); if ((respPDU != null) &&
pdu.add(new VariableBinding(levelOID)); pdu.add(new VariableBinding(effLevelOID)); response = snmp.get(pdu, target); PDU respPDU = response.getResponse(); if ((respPDU != null) &&
public void testGetSysName() throws IOException { Snmp snmp = new Snmp(new DefaultUdpTransportMapping()); snmp.listen(); Address addr = new UdpAddress(InetAddress.getLocalHost(), 9161); //Address addr = new UdpAddress(InetAddressUtils.addr("192.168.0.100"), 161); Target target = new CommunityTarget(addr, new OctetString("public")); target.setVersion(SnmpConstants.version1); target.setTimeout(3000); target.setRetries(3); PDUv1 getRequest = new PDUv1(); getRequest.add(new VariableBinding(new OID("1.3.6.1.2.1.1.5.0"))); ResponseEvent e = snmp.get(getRequest, target); PDU response = e.getResponse(); assertEquals(new OctetString("mockhost"), response.get(0).getVariable()); }