cleanup: containers (plugin) - add `inactive_file` to stats only if present

pull/2745/head
Bharath Vignesh J K 2024-04-30 01:33:11 +05:30
parent f640b6b8b4
commit b303001f58
2 changed files with 4 additions and 4 deletions

View File

@ -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):

View File

@ -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