uuidapache-nifiapache-minifi

Get UUID of System and Update as Attribute in NiFi FlowFile


Is there a way to get the unique UUID of the system (Generated using dmidecode) in NiFi and set it as an Attribute to a FlowFile.


Solution

  • Yeah. It can be done using ExecuteScript. You can use Groovy and execute as simple as the following line to run a shell command.

    "dmidecode".execute()
    

    or to read the result generated:

    def result = "dmidecode".execute().text
    

    Then when you're done reading the required value/data from the result, you can use something like the following to assign the value as a FlowFile attribute

    flowFile = session.get()
    if(!flowFile) return
    def dmidecodeUuid = ... // your logic to read the UUID from dmidecode
    flowFile = session.putAttribute(flowFile, 'dmidecode.uuid', dmidecodeUuid)
    session.transfer(flowFile, REL_SUCCESS)
    

    That's just a rough code which was quickly made. More details on ExecuteScript can be found at: