I am running telegraf as a docker container. I wanted to run a python script, for that i am using processors.execd plugin, but docker logs is showing exec format error.
My telegraf config file:
command = ["/etc/telegraf/cpu.py"]
data_format = “json”
json_strict = true
##fieldpass = [“counters_"]
json_time_key = “beginTime”
json_time_format = “unix”
tag_keys = [
json_string_fields = ["counters_”]
name_override = “data1”
Any solution would be helpful. Thanks
Thanks for the question.
exec format error in my experience suggests running a 64-bit binary on a 32-bit system, or an
armhf binary on
x86 or similar mis-match. What’s the first line of your
/etc/telegraf/cpu.py? Typically it might be something like
#!/usr/bin/env python or similar.
Thanks that line worked for me. But now its showed - permission denied. Earlier the python script was in etc/telegraf folder so i moved to tmp folder and then tried, still no results. Then i tried to run using sudo -
command = [“sudo”,“tmp/cpu.py”]
I am getting the error -
Conventional (standard) placement for your script would be somewhere like
/usr/local/bin. Does the script need root privs when run as a normal user such as yourself, in a terminal? If it indeed needs sudo, then you’ll likely need to specify the path to the sudo binary, as the environment (PATH) may not be setup correctly via execd. sudo typically lives somewhere like
/usr/bin/sudo. You may also need to configure sudo so it doesn’t ask for a password (which is the typically default behaviour) otherwise your execd call will hang as sudo waits for a password to run the script. But as I say, if it runs fine as you, from
/usr/local/bin then you may not even need sudo?