UP/DOWN Status of Docker Containers not Updating

I have an Ubuntu 22.04 host on which I run Docker. Check_MK Raw Edition (v2.3.0p13) runs as a Docker container. On the Host, a Check_MK agent runs. Also the Docker plugin runs. In Check_MK I see the host plus all running Docker containers, like this:

When I stop a container, I observe the following:

  • Docker Container Host state stays in (green) “UP” state
  • Docker Container Service “Check_MK“ switches to WARN
  • Docker Container Service “Check_MK Discovery“ switches to WARN
  • Other Docker Container Services switch to stale mode

The “Check_MK” service reports something like:
[piggyback] Successfully processed from source ‘host.docker.internal’, Missing monitoring data for plugins, cpu_utilization_os WARN, diskstat WARN, docker_container_status WARN, docker_container_status_uptime WARN, mem_used WARN, execution time 0.0 sec

Details:

When I go to Setup > Hosts > Host monitoring rules > Host check command > Edit rule: Host check command, I see this rule:

This lets me assume that the Docker Container Host state should depend on the “Docker container status”. However, as mentioned above, this service does not switch to WARN/ERROR state, but switches to stale mode when the container is stopped/removed and still reports “Container running on node …”.

So if I click a stopped/removed Container host, and then click the container name, I see this page:

I would like that a stopped/removed Docker Container Host switches to (yellow or red) “DOWN” host state. How to achieve this?

Any help is appreciated.

Additional information:

I noticed, that if the container fails to start and is configured to automatically restart, the “Docker container status” service reports “restarting” instead of “running”. Thus the container host state switches to “DOWN”, which is fine.

However, as described above, if the container is completely stopped/removed, the “Docker container status” service switches to stale mode (still reporting the last status of “running”), and (probably) thus the container host state stays in (green) UP state.

Any idea how to solve/fix this?

Any feedback?
Please let me know if the issue is not described clear enough. I would happily provide more information …

@andreas-doehler I didn’t get any responses to this post. You replied to earlier posts of mine and I see you are pretty active in this forum. So I wanted to ask if you have any idea about my problem or if you can point out somebody who might be able to help?

This is perfectly fine as in your case the container does not exists anymore → that means no data = stale service.

Why not change this rule for your need to the status of the “Check_MK service”. If the container not exists anymore then the Check_MK service will go to WARN normally as there is no data anymore - as it is also shown in your screenshot. You can also configure the behavior of the Check_MK service to your needs. Something like in this screenshot.

@andreas-doehler Thank you very much for your response.

I tried this:

However, the container host still shows as UP (even though the Check_MK service of the container host is currently in WARN state):

Did I get you wrong?

@andreas-doehler Thank you again for your response. However, as you can see from my reply, it’s still not clear to me. Would you mind to respond again? Any help is greatly appreciated.

→


Not like this - correct selection looks like

And how does your “Status of Checkmk services” rule looks like for this host?

@andreas-doehler Thank you very much for your response.

My instance shows me “Use the status of the Checkmk Agent” (instead of “… Service”). See following print screen. Did this changed in a very recent version? I use Checkmk Raw Edition 2.3.0p13 (in Docker).

So should I use “Use the status of the Checkmk Agent” or what should I use?

Please update this version, minimum to a current 2.3 version. Inside my test environment 2.3.0p42 the rule already looks like this.


It should work in your version with the selection of “Checkmk Agent” - but what is strange, is that i don’t see any werk mention the change of this rule set.

@andreas-doehler Thank you very much for your response!

I now updated to Checkmk Community (formerly Raw) v2.4.0p32 and see not the correct option:

Then I configured the status of the Checkmk services like this:

All pending changes applied.

Then I stopped a container. This still results in the container reporting like this (Check_MK in WARN state):

However, if I click the hostname “sqlbak” on that page, I see (Host is still in green UP state):

My main goal is to show hosts (which represent Docker containers) in a non-green, non-UP state. What am I missing?

The host shows the important information
“Always assumed to be up”
This should come from the setting “no IP” on this hosts.
I tested here in a system with also one host with setting “no IP” and it was all the time up.
Now i created this rule


You should set the conditions so, that only your containers are affected.
Result looks like this.

If my “Check_MK” service would be yellow (“Warn”) then CheckMK will interpret the status as UP

That means you need to configure your CheckMK service in a way that it gets CRIT if data is missing (Container switched of)

I hope this is understandable :wink: at the CMK conference writing is not so easy as in the home office.

@andreas-doehler Now it works. The missing piece was that my Checkmk service changed to WARN instead of CRIT, so the host remained in the green UP state.

Thanks again very much for your support, and all the best for the Checkmk Conference!

@andreas-doehler Sorry to bother you again. As I already said, it worked for some time. But then - after some hours - suddenly it stopped working again. This is my current configuration (which was working, but now does not work anymore):

“Host check command” rule:

“Status of the Checkmk services” rule:

Services of Docker container host which is currently not running:

Host status (again in green UP state):

As you can see, the “Check_MK” service of the “Sqlbak” host is now red. But the host shows as UP (again). Can you see what i am missing?

Anybody any idea.

@andreas-doehler Is it possible that this is a bug? I would be happy to help analyze this further if needed. Please let me know which logs, cache files, counters, or debug information would be useful to collect. If there is a way to reproduce or narrow this down together, I would gladly assist anytime.

According to your last screen shot the host is still considered to be “Always UP”.

Looks the Host check command “Use the status of the Check_MK Service” is not applied.

Either you did not activate the changes, the Rule is over ruled by an earlier rule or it could be an issue that you are using the host Label cmk/docker_object:container which is a discovered host label.
Better use the folder as condition.

So the host label cmk/docker_object:container is only there after the host got discovered once.

Could this be the issue?

@mimimi Your response lead me to the actual reason. My host check command rule used this condition:

image

My container host did have this tag, but some time after stopping the container, the container host seems to have lost this tag:

image

This also explains why my host check command rule configuration worked for some time and then stopped working.

I am now using an explicit host selection as the condition, which works for me.

However, just for my understanding: is it by design that a container host can effectively lose tags over time? Or is it more likely that I accidentally removed this tag, for example while running a service discovery? I do not remember doing that, but I also cannot confirm it with 100% certainty.

This is now the question :wink:
First you cannot remove manually labels detected by plugins.
The label is produced by one of the check plugins responsible for the docker checks. If this plugin gets no data anymore it is possible that the label gets removed at a automatic/manual discovery if selected to update labels there.

@andreas-doehler OK, now I understand what happened. (I had the “Update host labels” option set.)

Thank you all for your help on this topic.