snmpapache-nifireceiversnmp4jsnmp-trap

Snmp trap receiver as a custom processor in Apache Nifi


Objective:- Looking for an option to use SNMP trap receiving mechanism as a custom processor in Apache Nifi.

Looked at references like how to create a custom processor in Nifi (Apache docs and youtube videos), Nifi Source code of GetSNMP (including AbstractSNMPProcessor), ListenSysLog, GetFile etc.

Have got a simple (java code) SNMPTrap receiver using SNMP4J library and can listen to specific address with UDP or TCP based port. And then on occurence of a Trap (can be simulated by simple Java code of SNMP4J library) can print PDU details.

Now while trying to write this code within Nifi as a custom processor, not sure where to put my listen mechanism and then processing the actual PDU part. Kind of struck here.

More details :-

GetSNMP processor talks about a Specific OID and using that we have options of GET or Walk strategies to get info. Here (for my objective) looking for an option where Nifi server is running and want to get SNMP traps picked from specific system where Nifi is running. And for my objective, didn't get context to extend GetSNMP code.

In ListenSyslogProcessor, there was a blocking queue mechanism. And from it I could not derive to go for listening at an ip address for traps and how exactly to use ProcessContext, ProcessSession option of onTrigger method for a Nifi custom processor.

Any inputs are welcome...


Solution

  • One Possible Solution :-

    Could not create a Custom processor in Apache Nifi to Receive SNMP traps. Something else was possible, I will illustrate that here. It may be of some help to others.

    1. No change in the Java code
    2. Used ExecuteProcess Processor of Nifi to run the above Java code.
    3. On success result is pushed to further components in the Nifi Flow.

    Actually tried to catch SNMP traps using linux commands like net-snmp, snmptrapd. These options were not actually catching the SNMP traps, tested thru Java code trap sender and then Traps generated using commands from online sources.

    If you have better ideas, please share.