27 lines
673 B
Python
27 lines
673 B
Python
import requests
|
|
import time
|
|
from uptime import uptime
|
|
|
|
debug = 1
|
|
delay = 20
|
|
host='CHANGEME'
|
|
|
|
def send_data(results):
|
|
output = requests.post('http://192.168.1.231:8086/write?db=garagedb', data = results, timeout=30)
|
|
print(output)
|
|
|
|
def format_data(host, name, data):
|
|
results = '{},host={} value={}'.format(name, host, data)
|
|
send_data(results)
|
|
if debug == 1:
|
|
print(results)
|
|
|
|
while True:
|
|
format_data(host, 'sys_uptime', uptime())
|
|
|
|
f = open("/sys/class/thermal/thermal_zone0/temp", "r")
|
|
raw_temp = f.readline()
|
|
cpu_temperature = int(raw_temp) / 1000
|
|
format_data(host, 'cpu_temperature', cpu_temperature)
|
|
|
|
time.sleep(delay) |