[[inputs.exec]] plugin not working


The problem that I am having is modifying my telegraf.conf file to use the [[inputs.exec]] plugin, so that data can be sent from telegraf to influx.

Specifically, when I am in my CLI, I do a standard:

$ influx
Connected to http://localhost:8086 version 1.8.0
InfluxDB shell version: 1.8.0

use telegraf
Using database telegraf
show field keys from exec

What I want to display is the field keys from exec but nothing is being displayed, even though I have implemented the exec plugin along with the script I am executing. My guess is that I am implementing it in an incorrect manner? I have tried modifying my telegraf.conf in many ways, but with no luck.

For a visual reference, follow this link: https://blogs.cisco.com/developer/dna-center-noc-dashboard

From that article, where it says: “You will now see data being populated in influxdb.”, I am not seeing that data.

I am new to Telegraf, Influxdb and Grafana, so any help would be appreciated :slight_smile:

This is what I have in my telegraf.conf file:

command = ["/etc/telegraf/dnac_assurance.py"]
data_format = “json”
name_suffix = “_dnac”
interval = “1m”

Hello @dpatawaran,
Welcome! Can you please set debug=true on your telegraf config and share the output?

Thanks for replying,

By sharing the output, do you mean running Telegraf? This is what I get:

$ telegraf
2020-05-08T16:35:27Z I! Starting Telegraf 1.14.2
2020-05-08T16:35:27Z I! Using config file: /etc/telegraf/telegraf.conf
2020-05-08T16:35:27Z I! Loaded inputs: diskio net system netstat kernel cpu disk mem swap processes exec
2020-05-08T16:35:27Z I! Loaded aggregators:
2020-05-08T16:35:27Z I! Loaded processors:
2020-05-08T16:35:27Z I! Loaded outputs: influxdb
2020-05-08T16:35:27Z I! Tags enabled: host=HOSTNAME
2020-05-08T16:35:27Z I! [agent] Config: Interval:15s, Quiet:false, Hostname:“HOSTNAME”, Flush Interval:15s
2020-05-08T16:35:27Z D! [agent] Initializing plugins
2020-05-08T16:35:27Z D! [agent] Connecting outputs
2020-05-08T16:35:27Z D! [agent] Attempting connection to [outputs.influxdb]
2020-05-08T16:35:27Z D! [agent] Successfully connected to outputs.influxdb
2020-05-08T16:35:27Z D! [agent] Starting service inputs

Hello @dpatawaran,
Are you able to query Influxdb and get field values?

Yes, I am. However, none of the field keys from exec show up. Fields from every other plugin will show up though:

ex. > show field keys from cpu
name: cpu
fieldKey fieldType

usage_guest float
usage_guest_nice float
usage_idle float
usage_iowait float
usage_irq float
usage_nice float
usage_softirq float
usage_steal float
usage_system float
usage_user float

But the problem is here:

show field keys from exec

Okay can you please try:




Still nothing will show up,

I am thinking it may be something else within the inputs.exec plugin? Because when I start Telegraf, it shows that I am using the exec plugin, however none of the data is populating Influx. I have tried to research for hours about how to implement the inputs.exec plugin with correct syntax, but I haven’t found a solution yet.

Thank you for your help so far, I appreciate it.

Oh my bad, I thought you said you were successful in writing data. Absolutely, can you please share your config? As well as your json? Finally, thank you. for sharing the telegraf logs, but can you please include. the logs up until an error? Thank you.

Okay so this is my telegraf.config:

Global Telegraf Agent Configuration

hostname = “HOSTNAME”
flush_interval = “15s”
interval = “15s”

debug = true

Input Plugins

percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
ignore_fs = [“tmpfs”, “devtmpfs”, “devfs”]
[[inputs. io]]
[[inputs. net]]
#command = “/opt/telegraf/DNAC-NOC/dnac_assurance.py”
#data_format = “json”
#name_suffix = “_dnac”
#interval = “1m”

Output Plugin InfluxDB

database = “telegraf”
urls = [ “” ]
username = “telegraf”
password = “PASSWORD”

My impression was by putting the python file (dnac_assurance) as my command for my inputs.exec plugin, that it would execute that script when I call “show field keys from exec”

I am able to execute the dnac_assurance script successfully within the python environment, however the data doesn’t populate in Influx

When I execute the dnac_assurance.py script, I get the following json data:

{“totalscore”: 89, “totalcount”: 2401, “WLC.score”: 100, “WLC.count”: null, “AP.score”: 89, “AP.count”: null, “ALL-client.value”: 75, “ALL-client.count”: 266, “WIRED-client.value”: -1, “WIRED-client.count”: 0, “WIRELESS-client.value”: 75, “WIRELESS-client.count”: 266}

Hello to anyone needing this,

This has been solved.

In order to get this working to reflect in InfluxDB, I had to modify the telegraf.conf and implement the [[inputs.exec]] plugin. Whether you are using a script in commands = [""], or manually setting your preferences, this should be fine.

Still in the same telegraf.conf, I also had to implement [[outputs.exec]] within the output plugins. I then restarted telegraf and influx on my CLI, and entered into influx to display all of the field keys.

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.

Sorry for the delay! I’m happy you figured it out.