Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Deduct the cache figure from the memory usage when calculating the me…
Browse files Browse the repository at this point in the history
…mory.percentage metric
  • Loading branch information
Chris Gilbert committed Oct 22, 2018
1 parent 6f4e377 commit 3fe03c6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions dockerplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,6 @@ def read_memory_stats(container, dimensions, stats, t):
values = [mem_stats['limit'], mem_stats['max_usage'], mem_stats['usage']]
emit(container, dimensions, 'memory.usage', values, t=t)

mem_percent = 100.0 * mem_stats['usage'] / mem_stats['limit']
emit(container, dimensions, 'memory.percent', [mem_percent], t=t)

detailed = mem_stats.get('stats')
if detailed:
for key, value in detailed.items():
Expand All @@ -248,6 +245,14 @@ def read_memory_stats(container, dimensions, stats, t):
log.notice('No detailed memory stats available from container {0}.'
.format(_c(container)))

if detailed and detailed.get('cache'):
# If we have detailed memory stats then the page cache should be deducted from the usage figure
mem_percent = 100.0 * (mem_stats['usage'] - detailed['cache']) / mem_stats['limit']
else:
mem_percent = 100.0 * mem_stats['usage'] / mem_stats['limit']

emit(container, dimensions, 'memory.percent', [mem_percent], t=t)


def read_cpu_shares_stats(container,
container_inspect, cstats,
Expand Down

0 comments on commit 3fe03c6

Please sign in to comment.