diff --git a/custom_components/monitor_docker/helpers.py b/custom_components/monitor_docker/helpers.py index 1e1e230..fc719d9 100644 --- a/custom_components/monitor_docker/helpers.py +++ b/custom_components/monitor_docker/helpers.py @@ -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,