Improve parsing, ignore AUXTIN* sensors
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
af3df03b70
commit
0bd23b623b
1 changed files with 37 additions and 7 deletions
|
@ -1,22 +1,52 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import json
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
CRIT = 70.0
|
CRIT = 70.0
|
||||||
|
|
||||||
|
CHIP_BLACKLIST = []
|
||||||
|
SENSOR_BLACKLIST = [r'^AUXTIN[0-9]']
|
||||||
|
|
||||||
|
|
||||||
|
def in_blacklist(identifier, blacklist):
|
||||||
|
for entry in blacklist:
|
||||||
|
if entry == identifier or re.match(entry, identifier):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
sensors = subprocess.check_output(['sensors', '-u']).decode('utf-8')
|
sensors_data = json.loads(subprocess.check_output(
|
||||||
|
['sensors', '-j']).decode('utf-8'))
|
||||||
|
|
||||||
max_temp = 0.0
|
max_temp = 0.0
|
||||||
for line in sensors.split('\n'):
|
# for line in sensors.split('\n'):
|
||||||
if not re.match(r'.*temp._input:.*', line):
|
# if not re.match(r'.*temp._input:.*', line):
|
||||||
continue
|
# continue
|
||||||
temp = float(line.split(':')[1])
|
# temp = float(line.split(':')[1])
|
||||||
|
|
||||||
if temp > max_temp:
|
# if temp > max_temp:
|
||||||
max_temp = temp
|
# max_temp = temp
|
||||||
|
|
||||||
|
for chip, sensors in sensors_data.items():
|
||||||
|
if in_blacklist(chip, CHIP_BLACKLIST):
|
||||||
|
continue
|
||||||
|
|
||||||
|
for sensor, readings in sensors.items():
|
||||||
|
if in_blacklist(sensor, SENSOR_BLACKLIST):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if type(readings) == str:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for name, value in readings.items():
|
||||||
|
if not re.match(r'^temp._input$', name):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if value > max_temp:
|
||||||
|
max_temp = value
|
||||||
|
|
||||||
color = '#ffffff'
|
color = '#ffffff'
|
||||||
if max_temp > CRIT:
|
if max_temp > CRIT:
|
||||||
|
|
Loading…
Reference in a new issue