Get data from script check python to influxdb

influxdb

#1

Hi everyone, I have scripts write by python. When I run it, how to get result into influxdb?


#2

Hi this will help you :slight_smile:

https://www.influxdata.com/blog/getting-started-python-influxdb/


#3

Tks you, i have problem. I use exec to call file .py, it is wrong? Why?


#4

It looks ok at first sight , is there more detailed information in the log files ?


#5

I check in /var/log/kapacitor:
ts=2018-11-19T16:12:52.072+08:00 lvl=error msg=“exec command failed” service=kapacitor task_master=main task=chronograf-v1-8111d767-a15e-4853-b9d2-9eed11e80722 node=alert3 err=“exit status 1” output=“Hello\nTraceback (most recent call last):\n File “/tmp/hello.py”, line 5, in \n os.remove(’/tmp/my_file.txt’)\nOSError: [Errno 1] Operation not permitted: ‘/tmp/my_file.txt’\n”
ts=2018-11-19T16:12:52.126+08:00 lvl=error msg=“exec command failed” service=kapacitor task_master=main task=chronograf-v1-8111d767-a15e-4853-b9d2-9eed11e80722 node=alert3 err=“exit status 1” output=“Hello\nTraceback (most recent call last):\n File “/tmp/hello.py”, line 5, in \n os.remove(’/tmp/my_file.txt’)\nOSError: [Errno 1] Operation not permitted: ‘/tmp/my_file.txt’\n”

My hello.py file:
#!/usr/bin/python
import os

print “Hello”
os.remove(’/tmp/my_file.txt’)


#6

If you logon as user Kapacitor , can you run the python script without errors ? Maybe the permissions on the /tmp/my_file.txt don’t allow the operation ?


#7

Ahh, i don’t know user Kapacitor what i use?


#8

I think you will have to change the permissions on the file /tmp/my_file.txt
So that the kapacitor user can remove the file from within the TICKscript task.


#9

Ahh, oke, I fixed it, tks you :smiley: