paulbsd-salt/states/zabbix/scripts/pcsensor.py

16 lines
330 B
Python
Raw Normal View History

2022-01-07 13:18:24 +01:00
#!/usr/bin/python3
import re
import subprocess
tempre = re.compile(r" *(\d*\.\d*) C.*")
def temp_c():
res = subprocess.run("pcsensor", shell=True, capture_output=True)
line = res.stdout.decode().strip()
results = tempre.findall(line)
return float(results[0])
if __name__ == "__main__":
print(temp_c())