mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 23:26:29 +00:00
Fix add-on memory calculation (#3739)
Docker versions newer than 19.03 calculate memory usage sligthly different compared to previous versions. It seems the field "total_inactive_file" was not available in 19.03, so it can be used as indicator. See: https://docs.docker.com/engine/reference/commandline/stats/#description
This commit is contained in:
parent
8f84eaa096
commit
14bc771ba9
@ -14,9 +14,12 @@ class DockerStats:
|
|||||||
self._blk_write = 0
|
self._blk_write = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._memory_usage = (
|
if "total_inactive_file" in stats["memory_stats"]["stats"]:
|
||||||
stats["memory_stats"]["usage"] - stats["memory_stats"]["stats"]["cache"]
|
cache = stats["memory_stats"]["stats"]["total_inactive_file"]
|
||||||
)
|
else:
|
||||||
|
cache = stats["memory_stats"]["stats"]["cache"]
|
||||||
|
|
||||||
|
self._memory_usage = stats["memory_stats"]["usage"] - cache
|
||||||
self._memory_limit = stats["memory_stats"]["limit"]
|
self._memory_limit = stats["memory_stats"]["limit"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self._memory_usage = 0
|
self._memory_usage = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user