-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththermaldChecker.py
34 lines (29 loc) · 1004 Bytes
/
thermaldChecker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python -u
if __name__ == '__main__':
import time
from pystemd.systemd1 import Unit
import psutil
unit = Unit('thermald.service')
unit.load()
while True:
last_clocks = []
last_temps = []
reload_thermald = False
temps = psutil.sensors_temperatures()
for coreTemps in temps['coretemp']:
last_temps.append(round(coreTemps.current))
for core in psutil.cpu_freq(True):
current =round(core.current/1000, 1)
last_clocks.append(current)
if (all(i <= 1.0 for i in last_clocks) and all(i <= 70 for i in last_temps)):
reload_thermald = True
if (reload_thermald == True):
print('--- Temps ---')
print(last_temps)
print('------')
print('--- Clocks ---')
print(last_clocks)
print('------')
print('reload thermald!')
unit.Unit.Restart('replace')
time.sleep(2)