From 6af7ee3e76f11f7bf2c6677503aa764eb0db48c7 Mon Sep 17 00:00:00 2001 From: "Buhleier, Leon" Date: Fri, 21 Aug 2026 14:31:37 +0200 Subject: [PATCH 1/2] Added host labels for the checkmk agents version --- cmk/plugins/checkmk/agent_based/check_mk.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmk/plugins/checkmk/agent_based/check_mk.py b/cmk/plugins/checkmk/agent_based/check_mk.py index 76adb46e78c..294b36657ce 100644 --- a/cmk/plugins/checkmk/agent_based/check_mk.py +++ b/cmk/plugins/checkmk/agent_based/check_mk.py @@ -4,6 +4,8 @@ # conditions defined in the file COPYING, which is part of this source code package. +import re + from cmk.agent_based.v2 import ( AgentSection, Attributes, @@ -84,6 +86,11 @@ def host_label_function_labels(section: CheckmkSection) -> HostLabelGenerator: if (osversion := section.get("osversion")) is not None: yield HostLabel("cmk/os_version", osversion) + if (agent_version := section.get("version")) is not None: + yield HostLabel("cmk/agent_version", agent_version) + agent_major = re.match(r'[0-9.]+', agent_version) + yield HostLabel("cmk/agent_version_major", agent_major.group(0) if agent_major else agent_version) + agent_section_check_mk = AgentSection( name="check_mk", From d2eb4108ec032e53299e17c161b23c1c974f15da Mon Sep 17 00:00:00 2001 From: "Buhleier, Leon" Date: Fri, 21 Aug 2026 14:32:04 +0200 Subject: [PATCH 2/2] Formatting --- cmk/plugins/checkmk/agent_based/check_mk.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmk/plugins/checkmk/agent_based/check_mk.py b/cmk/plugins/checkmk/agent_based/check_mk.py index 294b36657ce..8bb30afc282 100644 --- a/cmk/plugins/checkmk/agent_based/check_mk.py +++ b/cmk/plugins/checkmk/agent_based/check_mk.py @@ -88,8 +88,10 @@ def host_label_function_labels(section: CheckmkSection) -> HostLabelGenerator: if (agent_version := section.get("version")) is not None: yield HostLabel("cmk/agent_version", agent_version) - agent_major = re.match(r'[0-9.]+', agent_version) - yield HostLabel("cmk/agent_version_major", agent_major.group(0) if agent_major else agent_version) + agent_major = re.match(r"[0-9.]+", agent_version) + yield HostLabel( + "cmk/agent_version_major", agent_major.group(0) if agent_major else agent_version + ) agent_section_check_mk = AgentSection(