Hi,
My previously working input.exec script suddenly doesn't work anymore since the update to Telegraf 1.5.2.
I'm getting the following error:
telegraf --config /etc/telegraf/telegraf.d/inputs_exec.conf --test
Data can be collected,but in fact, no data is collected.I doubt it is my telegraf user rights issue.My telegraf user is setting up /usr/sbin/nologin.
I don't want to change the situation of telegraf users.
Config:
[[inputs.exec]]
commands = ["bash /tmp/traceroute.sh"]
timeout = "10s"
data_format = "influx"
What version did you upgrade from?
Can you run this and add the output?:
sudo -u telegraf telegraf --config /etc/telegraf/telegraf.d/inputs_exec.conf --input-filter exec --test
output :
sudo -u telegraf telegraf --config /etc/telegraf/telegraf.d/inputs_exec.conf --input-filter exec --test
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for debian:
Did you type the password in?
NO,Because I don't know the password, either.
Let me know if you still have problems after you are able to test the script as the telegraf user. You can also try adding additional logging to your script (either to a file or to stderr). You probably also want to move your script out of /tmp since this directory is usually emptied on restart.
version: 1.6.3
Config:
[[inputs.exec]]
commands = ["/tmp/test.py"]
name_suffix = "_mycollector"
data_format = "json"
and run command, I get this:
# sudo -u telegraf telegraf --config /etc/telegraf/telegraf.conf --input-filter exec --test
* Plugin: inputs.exec, Collection 1
/tmp/test.py can working, but no data is collected.
@dangxiaojun What do you get if you run:
sudo -u telegraf /tmp/test.py
@danielnelson
Get this:
{"Field2": "2", "Field3": "3", "Field1": "1"}
You will need to update the JSON to have at least one numeric field. Strings are ignored unless they are listed in tag_keys, and you must have at least one field:
{"Field2": 2, "Field3": 3, "Field1": 1}
Yes, that's right. they are working now. Thx
Sorry to ask, but what do you run in your python script?
I mean if I just put:
print({"Field2": 2, "Field3": 3, "Field1": 1})
It doesn't return me anything.
Most helpful comment
NO,Because I don't know the password, either.