Docker memory usage uses the same algorithm than docker stats #2637

This commit is contained in:
Nicolas Hennion 2024-01-03 07:23:09 +00:00 committed by Bharath Vignesh J K
parent 8edf6e70b5
commit f640b6b8b4
3 changed files with 7 additions and 4 deletions

View File

@ -23,6 +23,7 @@ Under development: https://github.com/nicolargo/glances/issues?q=is%3Aopen+is%3A
alias=sda1:InternalDisk,sdb1:ExternalDisk
* Alert data model change from a list of list to a list of dict #2633
* Docker memory usage uses the same algorithm than docker stats #2637
===============
Version 3.4.0.5

View File

@ -54,7 +54,7 @@
{{ $filters.number(container.cpu_percent, 1) }}
</div>
<div class="table-cell">
{{ $filters.bytes(container.memory_usage_no_cache) }}
{{ $filters.bytes(container.memory_usage) }}
</div>
<div class="table-cell">
{{ $filters.bytes(container.limit) }}
@ -126,7 +126,7 @@ export default {
'status': containerData.status,
'uptime': containerData.uptime,
'cpu_percent': containerData.cpu.total,
'memory_usage_no_cache': memory_usage_no_cache,
'memory_usage': memory_usage_no_cache,
'limit': containerData.memory.limit != undefined ? containerData.memory.limit : '?',
'io_rx': containerData.io_rx != undefined ? containerData.io_rx : '?',
'io_wx': containerData.io_wx != undefined ? containerData.io_wx : '?',

View File

@ -120,7 +120,9 @@ class DockerStatsFetcher:
def _get_memory_stats(self):
"""Return the container MEMORY.
Output: a dict {'usage': ..., 'limit': ..., 'max_usage': ...}
Output: a dict {'usage': ..., 'limit': ..., 'inactive_file': ...}
Note:the displayed memory usage is 'usage - inactive_file'
"""
memory_stats = self._streamer.stats.get('memory_stats')
@ -131,7 +133,7 @@ class DockerStatsFetcher:
stats = {field: memory_stats[field] for field in self.MANDATORY_MEMORY_FIELDS}
# Optional field
# Optional field stats:inactive_file
stats['inactive_file'] = 0
if 'stats' in memory_stats:
stats['inactive_file'] = memory_stats['stats'].get('inactive_file', 0)