[[inputs.exec]] is not passing data to influxdb

Hello, I have previously posted about this topic before. However, I am now setting up telegraf/influxdb onto another machine now.

I have implemented the [[inputs.exec]] plugin as well as the [[outputs.exec]] plugin into /etc/telegraf/telegraf.conf. By doing this, it worked on my old machine. However, with this same implementation on my new machine, it isn’t passing data from the exec input plugin into influxdb.

I have also tested my [[inputs.exec]] plugin by doing:

sudo -u telegraf telegraf --config /etc/telegraf/telegraf.conf --input-filter exec --test

And it executes my script successfully. I am just wondering why the data isn’t being reflected in the influxdb.

Any help would be appreciated thanks!

Hello @dpatawaran,
Can you please share your config? Set debug=true in your config, and share your logs? Are you using the same version of Influxdb? What version are you using?
Thanks!

Hello, my log is saying:

Jun 1 16:02:00 isg-reporting telegraf[32552]: 2020-06-01T20:02:00Z E! [inputs.exec] Error in plugin: exec: exit status 1 for command ‘/home/patawdan/DNAC-NOC/dnac_assurance.py’: Traceback (most recent call last):…

Even though it’s giving me this error, I have tested the script within my machine and it is able to execute.

I am using Influxdb v1.8.0 and also Telegraf v.1.14.2

Hello @dpatawaran, Can you please share your telegraf config as well as your python script?

/etc/telegraf/telegraf.conf

Global Telegraf Agent Configuration

[agent]
hostname = “HOSTNAME”
flush_interval = “15s”
interval = “15s”

debug = true

Input Plugins

[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
[[inputs.disk]]
ignore_fs = [“tmpfs”, “devtmpfs”, “devfs”]
[[inputs.io]]
[[inputs.mem]]
[[inputs.net]]
[[inputs.system]]
[[inputs.swap]]
[[inputs.netstat]]
[[inputs.processes]]
[[inputs.kernel]]
[[inputs.exec]]
commands = ["/home/patawdan/DNAC-NOC/dnac_assurance.py"]
data_format = “json”
name_suffix = “_dnac”
interval = “1m”

Output Plugin InfluxDB

[[outputs.influxdb]]
database = “telegraf”
urls = [ “http://127.0.0.1:8086” ]
username = “telegraf”
password = “PASSWORD”

[[outputs.exec]]

/home/patawdan/DNAC-NOC/dnac_assurance.py

#!/usr/bin/env python3
from future import print_function
import time
import json
import os
import requests

turn off warninggs

requests.packages.urllib3.disable_warnings()
#from dnac_config import DNAC, DNAC_USER, DNAC_PASSWORD

DNAC= os.getenv(“DNAC”) or “"
DNAC_USER= os.getenv(“DNAC_USER”) or "
"
DNAC_PORT=os.getenv(“DNAC_PORT”) or 8086
DNAC_PASSWORD= os.getenv(“DNAC_PASSWORD”) or "
******”

from dnacentersdk import api

dnac = api.DNACenterAPI(base_url=‘https://{}:443’.format(DNAC),
username=DNAC_USER,password=DNAC_PASSWORD,verify=False)

network_health= dnac.networks.get_overall_network_health(timestamp=’’)
#print (json.dumps(network_health,indent=2))

timestamp = int(time.time() * 1000)
client_health= dnac.clients.get_overall_client_health(timestamp=’{}’.format(timestamp))
#print(json.dumps(client_health,indent=2))

result={}
for score in network_health.response:
result[“totalscore”] = score.healthScore
result[“totalcount”] = score.totalCount
for health in network_health.healthDistirubution:
result[health.category + “.score”] = health.healthScore
result[health.category + “.count”] = health.count
for score in client_health.response[0].scoreDetail:
result[score.scoreCategory.value + “-client.value”] = value=score.scoreValue
result[score.scoreCategory.value + “-client.count”] = score.clientCount

print(json.dumps(result))