mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fixed crash on CPU speed reading for certain systems
This commit is contained in:
parent
688117ec87
commit
8795a1eaf5
@ -19,12 +19,16 @@ class Stats:
|
|||||||
def get_node_stats(self):
|
def get_node_stats(self):
|
||||||
boot_time = datetime.datetime.fromtimestamp(psutil.boot_time())
|
boot_time = datetime.datetime.fromtimestamp(psutil.boot_time())
|
||||||
data = {}
|
data = {}
|
||||||
|
try:
|
||||||
|
cpu_freq = psutil.cpu_freq()
|
||||||
|
except NotImplementedError:
|
||||||
|
cpu_freq = psutil._common.scpufreq(current=0, min=0, max=0)
|
||||||
node_stats = {
|
node_stats = {
|
||||||
'boot_time': str(boot_time),
|
'boot_time': str(boot_time),
|
||||||
'cpu_usage': psutil.cpu_percent(interval=0.5) / psutil.cpu_count(),
|
'cpu_usage': psutil.cpu_percent(interval=0.5) / psutil.cpu_count(),
|
||||||
'cpu_count': psutil.cpu_count(),
|
'cpu_count': psutil.cpu_count(),
|
||||||
'cpu_cur_freq': round(psutil.cpu_freq()[0], 2),
|
'cpu_cur_freq': round(cpu_freq[0], 2),
|
||||||
'cpu_max_freq': psutil.cpu_freq()[2],
|
'cpu_max_freq': cpu_freq[2],
|
||||||
'mem_percent': psutil.virtual_memory()[2],
|
'mem_percent': psutil.virtual_memory()[2],
|
||||||
'mem_usage': helper.human_readable_file_size(psutil.virtual_memory()[3]),
|
'mem_usage': helper.human_readable_file_size(psutil.virtual_memory()[3]),
|
||||||
'mem_total': helper.human_readable_file_size(psutil.virtual_memory()[0]),
|
'mem_total': helper.human_readable_file_size(psutil.virtual_memory()[0]),
|
||||||
|
Loading…
Reference in New Issue
Block a user