Hi,
I want to excute a python script with the inputs.exec plugin , the configuration is:
[[inputs.exec]]
Commands array
commands = [“pythionE:/sw/telegraf_2/a.py” ]
name_suffix = “_mycollector”
data_format = “influx”
This is the a.py script, it does nothing interesting, but it is usefull for doing some tests:
import time
linea=‘example,tag1=a,tag2=b i=42i,j=43i,k=%ii’%int(time.time())
print(linea)
f_out=open(‘test.log’,‘a’)
f_out.write(linea+‘\n’)
f_out.close()
The script writes in the stdout a valid line for influxdb, also it writes to a file to check if it is executed. The line contains a timestamp for trace the test.log file.
If I run telegraf in test mode, it shows the output and test.log file is updated.
telegraf.exe --config telegraf.conf --debug --test
example_mycollector,host=vm-bar-gen-win1,tag1=a,tag2=b i=42i,j=43i,k=1663086182i 1663086182000000000
I created a telegraf service
telegraf.exe --service install --service-name telegraf_1 --service-display-name “telegraf_1” --config “E:\sw\telegraf\telegraf.conf”
The service is started OK but the test.log file is not writen nor the output file of outputs.file plugin. Configuring other input plugins as inputs.cpu or inputs.mem, they work ok, the only that is not executed is inputs.exec
Regards