mirror of
https://github.com/nicolargo/glances.git
synced 2024-08-17 00:10:48 +03:00
Raspberry PI - CPU info is not correct #2616
This commit is contained in:
parent
b2e5cb58c4
commit
65f84fd1e9
@ -23,7 +23,7 @@ class CpuPercent:
|
||||
self.percpu_percent = []
|
||||
|
||||
# Get CPU name
|
||||
self.__get_cpu_name()
|
||||
self.cpu_info['cpu_name'] = self.__get_cpu_name()
|
||||
|
||||
# cached_timer_cpu is the minimum time interval between stats updates
|
||||
# since last update is passed (will retrieve old cached info instead)
|
||||
@ -71,12 +71,19 @@ class CpuPercent:
|
||||
|
||||
def __get_cpu_name(self):
|
||||
# Get the CPU name once from the /proc/cpuinfo file
|
||||
# TODO: Multisystem...
|
||||
# Linux/Unix only
|
||||
# Read the first line with the "model name"
|
||||
ret = 'CPU'
|
||||
try:
|
||||
self.cpu_info['cpu_name'] = open('/proc/cpuinfo').readlines()[4].split(':')[1].strip()
|
||||
except (FileNotFoundError, PermissionError, IndexError, KeyError, AttributeError):
|
||||
self.cpu_info['cpu_name'] = 'CPU'
|
||||
return self.cpu_info['cpu_name']
|
||||
cpuinfo_file = open('/proc/cpuinfo').readlines()
|
||||
except (FileNotFoundError, PermissionError):
|
||||
pass
|
||||
else:
|
||||
for line in cpuinfo_file:
|
||||
if line.startswith('model name'):
|
||||
ret = line.split(':')[1].strip()
|
||||
break
|
||||
return ret
|
||||
|
||||
def __get_cpu(self):
|
||||
"""Update and/or return the CPU using the psutil library."""
|
||||
|
Loading…
Reference in New Issue
Block a user