diff --git a/cmk/plugins/checkmk/agent_based/check_mk.py b/cmk/plugins/checkmk/agent_based/check_mk.py index 76adb46e78c..8bb30afc282 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,13 @@ 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",