2018-12-02 23:43:08 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2019-07-31 10:32:42 +00:00
|
|
|
import json
|
2018-12-02 23:43:08 +00:00
|
|
|
import re
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
CRIT = 70.0
|
|
|
|
|
2019-07-31 10:32:42 +00:00
|
|
|
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
|
|
|
|
|
2018-12-02 23:43:08 +00:00
|
|
|
|
|
|
|
def main():
|
2019-07-31 10:32:42 +00:00
|
|
|
sensors_data = json.loads(subprocess.check_output(
|
|
|
|
['sensors', '-j']).decode('utf-8'))
|
2018-12-02 23:43:08 +00:00
|
|
|
|
|
|
|
max_temp = 0.0
|
2019-07-31 10:32:42 +00:00
|
|
|
# for line in sensors.split('\n'):
|
|
|
|
# if not re.match(r'.*temp._input:.*', line):
|
|
|
|
# continue
|
|
|
|
# temp = float(line.split(':')[1])
|
|
|
|
|
|
|
|
# if temp > max_temp:
|
|
|
|
# max_temp = temp
|
|
|
|
|
|
|
|
for chip, sensors in sensors_data.items():
|
|
|
|
if in_blacklist(chip, CHIP_BLACKLIST):
|
2018-12-02 23:43:08 +00:00
|
|
|
continue
|
|
|
|
|
2019-07-31 10:32:42 +00:00
|
|
|
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
|
2018-12-02 23:43:08 +00:00
|
|
|
|
2018-12-03 14:22:12 +00:00
|
|
|
color = '#ffffff'
|
2018-12-02 23:43:08 +00:00
|
|
|
if max_temp > CRIT:
|
|
|
|
color = '#dd0000'
|
|
|
|
|
2018-12-03 14:22:12 +00:00
|
|
|
text = '\uf2c7 <span color="{}">{:.1f}°C</span>'.format(color, max_temp)
|
|
|
|
|
|
|
|
print(text)
|
2018-12-02 23:43:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|