Closed ranrinc closed 2 years ago
Just found out that the problem is being Debian 11 is implementing a new cgroup from v1 to v2 which creates changes in getting stats. Will the add-on fixed the problem too?
I had same problems, as a tmp quick fix I simple changed the following in helpers.py
# Gather memory information
memory_stats = {}
try:
# Memory is in Bytes, convert to MBytes
memory_stats["usage"] = toMB(
raw["memory_stats"]["usage"] - raw["memory_stats"]["stats"]["inactive_file"]
)
memory_stats["limit"] = toMB(raw["memory_stats"]["limit"])
# memory_stats["max_usage"] = toMB(raw["memory_stats"]["max_usage"])
memory_stats["usage_percent"] = round(
float(memory_stats["usage"]) / float(memory_stats["limit"]) * 100.0,
PRECISION,
)
From https://docs.docker.com/engine/reference/commandline/stats/
On Linux, the Docker CLI reports memory usage by subtracting cache usage from the total memory usage. The API does not perform such a calculation but rather provides the total memory usage and the amount from the cache so that clients can use the data as needed. The cache usage is defined as the value of total_inactive_file field in the memory.stat file on cgroup v1 hosts.
On Docker 19.03 and older, the cache usage was defined as the value of cache field. On cgroup v2 hosts, the cache usage is defined as the value of inactive_file field.
raw["memory_stats"]["usage"] - raw["memory_stats"]["stats"]["inactive_file"]
yay it works.. thanks, man.
How about a PR then?
How about a PR then?
The credit goes to @KalleDK ... else I already do a PR hahahaha...
I don't know how to test if their are cgroup1 or 2 which would be needed in order not to break the older
I don't know how to test if there are cgroup1 or 2 which would be needed in order not to break the older
you are correct on that issue. I know how to check using docker command, but that is as far as getting info
docker info | grep -i cgroup
Just applied the workaround was mentioned above in the master. Can anybody test the new "helpers.py" out and let me know?
File modified: https://github.com/ualex73/monitor_docker/blob/master/custom_components/monitor_docker/helpers.py
Shouldn't it be
if "cache" in raw["memory_stats"]["stats"]:
if "cache" in raw:
Also this wont work in the new cgroup, as I read there is no substitute for it. Ref
memory_stats["max_usage"] = toMB(raw["memory_stats"]["max_usage"])
But I don't see it used anywhere else in the code... So can it just be removed? Or "deprecated" by moving it to the Debian 10 section.. So if you are on 10 you can still use it, but on 11 it's missing
@KalleDK thanks it is merged. I will do a test tomorrow/friday and then release it as a version (then it shows up in HACS)
@KalleDK thanks it is merged. I will do a test tomorrow/friday and then release it as a version (then it shows up in HACS)
great.. can wait till it's up. Since the latest HA already making Debian 11 official
It is merged a while ago, so I will close this one.
I just created 1.11-beta, where I tweaked the memory code a bit more. Now it checks the docker version first, before making a decision which field it should pick.
After the upgrade, my os from Debian 10 to Debian 11 all my stats disappear from both portainer and monitor_docker. Is there a solution for this? Especially since HA will soon be upgrading its supervised version to Debian 11.
Debian 11![Screen Shot 2021-08-29 at 9 20 41 PM](https://user-images.githubusercontent.com/15801696/131253982-eb7e88ec-fd5f-4dfc-b45e-9d5bb0a0265b.png)
basically due to the new cgroup v2 on Debian 11 create error on monitor Docker