monitor_docker icon indicating copy to clipboard operation
monitor_docker copied to clipboard

Cannot determine memory usage for container ('usage')

Open AndreKR opened this issue 8 months ago • 6 comments

I just installed monitor_docker but no entities are created and my log is full of these messages:

2025-04-05 02:42:50.690 ERROR (Dummy-1) [custom_components.monitor_docker.helpers] [Americano] node-red: Cannot determine memory usage for container ('usage')
2025-04-05 02:42:50.691 ERROR (Dummy-1) [custom_components.monitor_docker.helpers] [Americano] node-red: Raw 'memory_stats' {'stats': {'active_anon': 0, 'active_file': 0, 'anon': 0, 'anon_thp': 0, 'file': 0, 'file_dirty': 0, 'file_mapped': 0, 'file_writeback': 0, 'inactive_anon': 0, 'inactive_file': 0, 'kernel_stack': 0, 'pgactivate': 0, 'pgdeactivate': 0, 'pgfault': 0, 'pglazyfree': 0, 'pglazyfreed': 0, 'pgmajfault': 0, 'pgrefill': 0, 'pgscan': 0, 'pgsteal': 0, 'shmem': 0, 'slab': 0, 'slab_reclaimable': 0, 'slab_unreclaimable': 0, 'sock': 0, 'thp_collapse_alloc': 0, 'thp_fault_alloc': 0, 'unevictable': 0, 'workingset_activate': 0, 'workingset_nodereclaim': 0, 'workingset_refault': 0}}

I don't even know if the messages are related to the missing entities, but something isn't right.

AndreKR avatar Apr 05 '25 00:04 AndreKR

The required memory fields are missing in your output. What type of Docker/operation system/etc are you running?

ualex73 avatar Apr 05 '25 18:04 ualex73

Raspberry Pi OS, completely standard Docker installation.

AndreKR avatar Apr 05 '25 21:04 AndreKR

Can you check with "docker stats" if you see the memory? The output should look like:

CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS c37466cecaf3 zigbee2mqtt 0.00% 55.04MiB / 7.878GiB 0.68% 1.65MB / 2.23MB 111kB / 233kB 12

Check the "MEM USAGE" value?

ualex73 avatar Apr 06 '25 18:04 ualex73

It's "0B / 0B" for all containers.

Image

From a quick Google search it appears this is normal on a Pi because the kernel doesn't have cgroup memory accounting enabled.

AndreKR avatar Apr 06 '25 20:04 AndreKR

The following is mentioned in the README:

Raspberry Pi (Raspbian)

Using a Raspberry Pi with Raspbian it could happen no memory is reported. In such case, the Docker API does not report it to Monitor Docker. Making the following changes normally fixes the problem:

Open the file /boot/cmdline.txt Add the following to the end of the existing line cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory Reboot your Raspberry Pi NOTE: Add the line to the existing line, do not replace it

ualex73 avatar Apr 07 '25 12:04 ualex73

I should clarify that I'm not even trying to monitor memory use, my config is just:

monitor_docker:
  - name: Americano
    containers_exclude:
      - chirpstack-docker-chirpstack-rest-api-1
      - chirpstack-docker-chirpstack-gateway-bridge-1
      - chirpstack-docker-chirpstack-gateway-bridge-basicstation-1
      - chirpstack-docker-postgres-1
      - chirpstack-docker-mosquitto-1
      - chirpstack-docker-redis-1
    monitored_conditions:
      - version
      - containers_running
      - containers_total
      - state
      - status
      - health
      - image

I don't think I should have to enable a kernel setting to use Monitor Docker on a Pi, especially when I'm not trying to monitor memory usage. Do you disagree?

AndreKR avatar Apr 07 '25 13:04 AndreKR