See TODO in:

- glances/plugins/processlist/__init__.py
- glances/outputs/glances_restful_api.py
This commit is contained in:
nicolargo 2023-12-10 20:27:31 +01:00
parent c4a631a25f
commit e27fd5f102
2 changed files with 8 additions and 5 deletions

View File

@ -142,6 +142,7 @@ class PluginModel(GlancesPluginModel):
will be replaced by:
{'rss': 6377472, 'vms': 13946880, 'shared': 4100096, 'text': 913408, 'lib': 0, 'data': 2289664, 'dirty': 0}
"""
# TODO: When the WebUI is displayed, this function is call > 2 times per second... Why ???
return [{k: (v._asdict() if hasattr(v, '_asdict') else v) for k, v in p.items()} for p in self.stats]
def update(self):

View File

@ -23,9 +23,9 @@ def create_program_dict(p):
'num_threads': p['num_threads'] or 0,
'cpu_percent': p['cpu_percent'] or 0,
'memory_percent': p['memory_percent'] or 0,
'cpu_times': p['cpu_times'] or (),
'memory_info': p['memory_info'] or (),
'io_counters': p['io_counters'] or (),
'cpu_times': p['cpu_times'] or {},
'memory_info': p['memory_info'] or {},
'io_counters': p['io_counters'] or {},
'childrens': [p['pid']],
# Others keys are not used
# but should be set to be compliant with the existing process_list
@ -44,8 +44,10 @@ def update_program_dict(program, p):
program['num_threads'] += p['num_threads'] or 0
program['cpu_percent'] += p['cpu_percent'] or 0
program['memory_percent'] += p['memory_percent'] or 0
program['cpu_times'] = dict(Counter(program['cpu_times']) + Counter(p['cpu_times']))
program['memory_info'] = dict(Counter(program['memory_info']) + Counter(p['memory_info']))
program['cpu_times'] = dict(Counter(program['cpu_times'] or {}) +
Counter(p['cpu_times'] or {}))
program['memory_info'] = dict(Counter(program['memory_info'] or {}) +
Counter(p['memory_info'] or {}))
program['io_counters'] += p['io_counters']
program['childrens'].append(p['pid'])