Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions sysmontask/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ def cpuUpdate(self):
temperatures_list=ps.sensors_temperatures()
if 'coretemp' in temperatures_list:
self.cpuTempLabelValue.set_text('{0} °C'.format(int(temperatures_list['coretemp'][0][1])))

## amd cpu package temp
elif 'k10temp' in temperatures_list:
for lis in temperatures_list['k10temp']:
Expand All @@ -181,6 +180,13 @@ def cpuUpdate(self):
if lis.label=='Tdie':
self.cpuTempLabelValue.set_text('{0} °C'.format(int(lis.current)))
break
else:
try:
fan_list = ps.sensors_fans()
cpu_temp = cpuTempByFanMatching(temperatures_list, fan_list)
self.cpuTempLabelValue.set_text('{0} °C'.format(int(cpu_temp.current)))
except:
pass

# cpu fan speed
except:
Expand All @@ -200,4 +206,27 @@ def cpuUpdate(self):
self.cpuUtilArray.insert(0,self.cpuUtil)
for i in range(self.cpu_logical_cores):
self.cpu_logical_cores_util_arrays[i].pop()
self.cpu_logical_cores_util_arrays[i].insert(0,temp[i])
self.cpu_logical_cores_util_arrays[i].insert(0,temp[i])


def cpuTempByFanMatching(sensors_temp, sensors_fan):
temp_keys = list(sensors_temp.keys())
fan_keys = list(sensors_fan.keys())

# Detect first fan key which matches temperature key
try:
sensor_name = helperMatchFirstKey(temp_keys, fan_keys)
except NameError:
raise NameError("Cannot identify cpu sensor")

# Return first temperature
temps = sensors_temp[sensor_name]
return temps[0]


def helperMatchFirstKey(temp_keys, fan_keys):
for fan_name in fan_keys:
for temp_name in temp_keys:
if fan_name == temp_name:
return temp_name
raise NameError("No matching fan and temperature name found!")