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