Docker Plugin - if statements dont work properly

CMK version:2.0.0
OS version: Debian 11 Bullseye

It seems checkmk cant handle stringfilter if statements. My code:

from .agent_based_api.v1 import *
import socket

def discover_docker_check(section):
    yield Service()

def check_docker_check(section):
    server = str(section).replace("[","").replace(",","").replace("'","").replace("]","")
    if "online" or "is running" in server:
        yield Result(state=State.OK, summary=f"Status: {server}")
    else:
        yield Result(state=State.CRIT, summary=f"Status: {server}")
        return

register.check_plugin(
    name="docker_db_check",
    service_name="Docker DB Check",
    discovery_function=discover_docker_check,
    check_function=check_docker_check,
)

In the check mk monitoring the service is still marked as OK, even if the output of the section is empty (i already checked with the f strings integrated after i shut down the docker container - there should be no “is running” or “online” in the section, sadly the filter still doesnt work). Why does check mk ignore if statements with any logic outside of “= 0”? this really makes it hard to design any custom plugin

CMK is not ignoring the if statement. All valid Python programming is possible inside your check function.
What you should do is - add some debug output to see what CMK has inside the “server” variable at execution time. Then you should execute it on command line with “cmk --debug -vvn hostname” to see what happens.

For check development i would recommend a runtime environment like this

or my modified version

These dev environments have nice options for debugging with break points and so on.