Skip to content

Fix memory calculations when "stats" is not present in "memory_stats" #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions custom_components/monitor_docker/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1145,10 +1145,11 @@ async def _run_container_stats(self) -> None:
cache = 0
# https://docs.docker.com/engine/reference/commandline/stats/
# Version is 19.04 or higher, don't use "cache"
if "total_inactive_file" in raw["memory_stats"]["stats"]:
cache = raw["memory_stats"]["stats"]["total_inactive_file"]
elif "inactive_file" in raw["memory_stats"]["stats"]:
cache = raw["memory_stats"]["stats"]["inactive_file"]
if "stats" in raw["memory_stats"]:
if "total_inactive_file" in raw["memory_stats"]["stats"]:
cache = raw["memory_stats"]["stats"]["total_inactive_file"]
elif "inactive_file" in raw["memory_stats"]["stats"]:
cache = raw["memory_stats"]["stats"]["inactive_file"]

memory_stats["usage"] = toMB(
raw["memory_stats"]["usage"] - cache,
Expand Down