From e9d16763f9770ed4732069eca3c1f740f97dde55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Henrique=20Ferreira=20de=20Freitas?= Date: Fri, 4 Nov 2016 09:32:32 -0200 Subject: [PATCH] NIFI-3014 GetSNMP add textual oid attribute to flowfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Henrique Ferreira de Freitas --- .../org/apache/nifi/snmp/processors/GetSNMP.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/main/java/org/apache/nifi/snmp/processors/GetSNMP.java b/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/main/java/org/apache/nifi/snmp/processors/GetSNMP.java index bb59fe7ec6b7..19af7440e933 100644 --- a/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/main/java/org/apache/nifi/snmp/processors/GetSNMP.java +++ b/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/main/java/org/apache/nifi/snmp/processors/GetSNMP.java @@ -32,6 +32,7 @@ import org.apache.nifi.processor.ProcessSession; import org.apache.nifi.processor.Processor; import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.processor.exception.ProcessException; import org.snmp4j.PDU; import org.snmp4j.event.ResponseEvent; @@ -58,6 +59,16 @@ public class GetSNMP extends AbstractSNMPProcessor { .addValidator(SNMPUtils.SNMP_OID_VALIDATOR) .build(); + /** Textual OID to request */ + public static final PropertyDescriptor TEXTUAL_OID = new PropertyDescriptor.Builder() + .name("snmp-textual-oid") + .displayName("Textual OID") + .description("The textual OID to request") + .required(false) + .addValidator(StandardValidators.NON_BLANK_VALIDATOR) + .defaultValue(null) + .build(); + /** SNMP strategy for SNMP Get processor : simple get or walk */ public static final PropertyDescriptor SNMP_STRATEGY = new PropertyDescriptor.Builder() .name("snmp-strategy") @@ -93,6 +104,7 @@ public class GetSNMP extends AbstractSNMPProcessor { static { List _propertyDescriptors = new ArrayList<>(); _propertyDescriptors.add(OID); + _propertyDescriptors.add(TEXTUAL_OID); _propertyDescriptors.add(SNMP_STRATEGY); _propertyDescriptors.addAll(descriptors); propertyDescriptors = Collections.unmodifiableList(_propertyDescriptors); @@ -122,6 +134,8 @@ protected void onTriggerSnmp(ProcessContext context, ProcessSession processSessi FlowFile flowFile = processSession.create(); PDU pdu = response.getResponse(); flowFile = SNMPUtils.updateFlowFileAttributesWithPduProperties(pdu, flowFile, processSession); + flowFile = SNMPUtils.addAttribute(SNMPUtils.SNMP_PROP_PREFIX + "textualOid", + context.getProperty(TEXTUAL_OID).getValue(), flowFile, processSession); processSession.getProvenanceReporter().receive(flowFile, this.snmpTarget.getAddress().toString() + "/" + context.getProperty(OID).getValue()); if(pdu.getErrorStatus() == PDU.noError) {