Add sys_uptime.py

This commit is contained in:
smallsolar 2024-05-02 07:23:14 +00:00
parent 640a605814
commit 289d5b1728
1 changed files with 22 additions and 0 deletions

22
sys_uptime.py Normal file
View File

@ -0,0 +1,22 @@
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 = 'sys_{},host={} value={}'.format(name, host, data)
send_data(results)
if debug == 1:
print(results)
while True:
format_data(host, 'uptime', uptime())
time.sleep(delay)