diff options
author | Bharath Vignesh J K <52282402+RazCrimson@users.noreply.github.com> | 2024-04-30 01:33:11 +0530 |
---|---|---|
committer | Bharath Vignesh J K <52282402+RazCrimson@users.noreply.github.com> | 2024-04-30 01:33:11 +0530 |
commit | b303001f58b82713d4e1d99c10e7af49841425d3 (patch) | |
tree | ea3d759c83a809656986e2dd7217e32f936b940c | |
parent | f640b6b8b453a2a6d2a575b46785191dd8ab1cba (diff) |
cleanup: containers (plugin) - add `inactive_file` to stats only if present
-rw-r--r-- | glances/plugins/containers/__init__.py | 1 | ||||
-rw-r--r-- | glances/plugins/containers/engines/docker.py | 7 |
2 files changed, 4 insertions, 4 deletions
diff --git a/glances/plugins/containers/__init__.py b/glances/plugins/containers/__init__.py index 6c0134f5..9ccc5ed7 100644 --- a/glances/plugins/containers/__init__.py +++ b/glances/plugins/containers/__init__.py @@ -258,6 +258,7 @@ class PluginModel(GlancesPluginModel): def memory_usage_no_cache(self, mem): """Return the 'real' memory usage by removing inactive_file to usage""" + # Ref: https://github.com/docker/docker-py/issues/3210 return mem['usage'] - (mem['inactive_file'] if 'inactive_file' in mem else 0) def update_views(self): diff --git a/glances/plugins/containers/engines/docker.py b/glances/plugins/containers/engines/docker.py index 1ac2cab1..37267830 100644 --- a/glances/plugins/containers/engines/docker.py +++ b/glances/plugins/containers/engines/docker.py @@ -133,10 +133,9 @@ class DockerStatsFetcher: stats = {field: memory_stats[field] for field in self.MANDATORY_MEMORY_FIELDS} - # Optional field stats:inactive_file - stats['inactive_file'] = 0 - if 'stats' in memory_stats: - stats['inactive_file'] = memory_stats['stats'].get('inactive_file', 0) + # Optional field stats: inactive_file + if memory_stats.get('stats', {}).get('inactive_file') is not None: + stats['inactive_file'] = memory_stats['stats']['inactive_file'] # Return the stats return stats |