From 7289fc705790691f4059772df3214c503c3786c0 Mon Sep 17 00:00:00 2001 From: Florent <25004801+FlorentLM@users.noreply.github.com> Date: Wed, 12 Feb 2020 17:59:26 +0100 Subject: [PATCH] Added basic fan status logging Added basic fan status logging for use with external metrics collectors (such as Telegraf) --- examples/automatic.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/automatic.py b/examples/automatic.py index 846688f..0be73da 100755 --- a/examples/automatic.py +++ b/examples/automatic.py @@ -46,6 +46,11 @@ def update_led_temperature(temp): led_busy.release() +def update_status_file(status): + with open("/var/log/fanshim_status", "w") as f: + f.write(str(int(status))) + + def get_cpu_temp(): t = psutil.sensors_temperatures() for x in ['cpu-thermal', 'cpu_thermal']: @@ -149,6 +154,8 @@ def held_handler(): if set_fan(enable): last_change = t + update_status_file(enable) + if not args.noled: update_led_temperature(t)