Hi kostas, Thanks for your reply.
I have given the script full permissions (`chmod 777`) and the problem remains. The telegraf version I'm running is 'Telegraf - version 0.13.1'. The weirdest thing is I just tried the same with some dummy python script: ``` #!/usr/bin/env python import json from datetime import datetime dict_list = [] n = 66.666 s = datetime.now().second x = "boing" dict_list.append(dict(seconds=s,order=n,description=x)) print(json.dumps(dict_list[0])) ``` telegraf.conf: ``` [[inputs.exec]] command = "/home/dummy.py" data_format = "json" ##name_suffix = "_dummy" name_override = 'dummy' timeout = "10s" tag_keys = ['description'] ``` ... and it works perfectly! I've noticed that while the output of dummy.py is printed immediately to the stdout, the one from my_script takes a few seconds to show up. Could this be the problem? Doesn't the 'timeout' config handle this? On Tue, Aug 2, 2016 at 1:42 PM, <[email protected]> wrote: > On Tuesday, August 2, 2016 at 1:06:06 PM UTC+3, [email protected] wrote: > > Hi all, > > > > I'm trying to capture the json output of a python script using the Exec > Input Plugin. For some reason, I'm getting the following error when > telegraf tries to execute the script and collect the metrics: > > > > ``` > > telegraf_1 | 2016-08-02T09:43:00.360767123Z 2016/08/02 09:43:00 ERROR > in input [exec]: exec: exit status 1 for command '/home/myscript.py' > > ``` > > > > The relevant entry of telegraf.conf file loos like the following: > > > > ``` > > [[inputs.exec]] > > command = "/home/myscript.py" > > data_format = "json" > > name_suffix = "_some_suffix" > > timeout = "10s" > > tag_keys = ["key", "unit"] > > ``` > > > > /home/myscript.py has execution permissions ('chmod +x') and outputs the > following: > > > > ``` > > {"key": "some_key", "value": 28.214, "unit": "ms"} > > > > ``` > > > > I've checked that the exit status of running `/home/myscript.py` is 0. > > > > > > The weirdest part is that, if I run `$ telegraf -config > /etc/telegraf.conf` -test`, I get a successful output: > > > > ``` > > * Plugin: exec, Collection 1 > > > exec_some_suffix,host=13ceb7312093,key=some_key,unit=ms value=19.539 > 1470132272694745614 > > ``` > > > > Do you have any idea of what could be happening? > > Hi, > > I have not been able to reproduce this behavior with the latest beta of > Telegraf. > > It is likely that when you execute telegraf by invoking the binary from > the command line (telegraf -config /etc/telegraf.conf) you are running it > as your user who has privileges to execute the python script, while the > telegraf service runs as user "telegraf", which may not have sufficient > privileges to access /home/myscript.py > > -- Remember to include the InfluxDB version number with all issue reports --- You received this message because you are subscribed to the Google Groups "InfluxDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/influxdb. To view this discussion on the web visit https://groups.google.com/d/msgid/influxdb/CAF8xhAu8Rih%2BZGj8K62wn5GLxgs-UmEk6nUZDaBOuPz3rpGZ%3DQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
