diff options
author | nicolargo <nicolas@nicolargo.com> | 2024-04-24 12:28:48 +0200 |
---|---|---|
committer | nicolargo <nicolas@nicolargo.com> | 2024-04-24 12:28:48 +0200 |
commit | c2fe2de35509ef7683204e3549bdcc983d5d934a (patch) | |
tree | 66830a524ce035fb1a75412b246459a8a2a7ff3c | |
parent | 75b06ed4b1dca291369d4e582ca93aebb1131249 (diff) |
Export individual processes stats - Export dict are now sorted #794
-rw-r--r-- | glances/exports/export.py | 2 | ||||
-rw-r--r-- | glances/processes.py | 24 |
2 files changed, 11 insertions, 15 deletions
diff --git a/glances/exports/export.py b/glances/exports/export.py index aaa6e045..fe710ee0 100644 --- a/glances/exports/export.py +++ b/glances/exports/export.py @@ -183,7 +183,7 @@ class GlancesExport(object): else: pre_key = '' # Walk through the dict - for key, value in iteritems(stats): + for key, value in sorted(iteritems(stats)): if isinstance(value, bool): value = json_dumps(value) if isinstance(value, list): diff --git a/glances/processes.py b/glances/processes.py index 7ba12eb7..79eae3ae 100644 --- a/glances/processes.py +++ b/glances/processes.py @@ -42,11 +42,6 @@ class GlancesProcesses(object): # Should be set by the set_args method self.args = None - # Add internals caches because psutil do not cache all the stats - # See: https://github.com/giampaolo/psutil/issues/462 - self.username_cache = {} - self.cmdline_cache = {} - # The internals caches will be cleaned each 'cache_timeout' seconds self.cache_timeout = cache_timeout # First iteration, no cache @@ -363,14 +358,14 @@ class GlancesProcesses(object): def is_selected_extended_process(self, position): """Return True if the process is the selected one for extended stats.""" return ( - hasattr(self.args, 'programs') - and not self.args.programs - and hasattr(self.args, 'enable_process_extended') - and self.args.enable_process_extended - and not self.disable_extended_tag - and hasattr(self.args, 'cursor_position') - and position == self.args.cursor_position - and not self.args.disable_cursor + hasattr(self.args, 'programs') and + not self.args.programs and + hasattr(self.args, 'enable_process_extended') and + self.args.enable_process_extended and + not self.disable_extended_tag and + hasattr(self.args, 'cursor_position') and + position == self.args.cursor_position and + not self.args.disable_cursor ) def update(self): @@ -389,7 +384,8 @@ class GlancesProcesses(object): ##################### sorted_attrs = ['cpu_percent', 'cpu_times', 'memory_percent', 'name', 'status', 'num_threads'] displayed_attr = ['memory_info', 'nice', 'pid'] - # 'name' can not be cached because it is used for filtering + # The following attributes are cached and only retreive every self.cache_timeout seconds + # Warning: 'name' can not be cached because it is used for filtering cached_attrs = ['cmdline', 'username'] # Some stats are optional |