Skip to content

Commit

Permalink
Docker memory usage uses the same algorithm than docker stats #2637
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolargo authored and RazCrimson committed Apr 29, 2024
1 parent 8edf6e7 commit f640b6b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.rst
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions glances/outputs/static/js/components/plugin-containers.vue
Expand Up @@ -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) }}
Expand Down Expand Up @@ -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 : '?',
Expand Down
6 changes: 4 additions & 2 deletions glances/plugins/containers/engines/docker.py
Expand Up @@ -120,7 +120,9 @@ def _get_cpu_stats(self):
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')

Expand All @@ -131,7 +133,7 @@ def _get_memory_stats(self):

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)
Expand Down

0 comments on commit f640b6b

Please sign in to comment.