added cpu temperature monitor

This commit is contained in:
smallsolar 2024-05-12 20:43:32 +00:00
parent 48c66e007d
commit 8c7b2687d6
1 changed files with 7 additions and 2 deletions

View File

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