CMK version: 2.4.0p20
Error message: value of ‘detect’ keywords third element must be a boolean: None
Output of “cmk --debug -vvn hostname”: (If it is a problem with checks or plugins)
Traceback (most recent call last):
File “/omd/sites/Demo/bin/cmk”, line 135, in
errors = config.load_all_plugins(
^^^^^^^^^^^^^^^^^^^^^^^^
File “/omd/sites/Demo/lib/python3/cmk/base/config.py”, line 1425, in load_all_plugins
errors = agent_based_register.load_all_plugins(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/omd/sites/Demo/lib/python3.12/contextlib.py”, line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File “/omd/sites/Demo/lib/python3/cmk/base/api/agent_based/register/_discover.py”, line 76, in load_all_plugins
_register_plugin_by_type(location, plugin, validate=raise_errors)
File “/omd/sites/Demo/lib/python3/cmk/base/api/agent_based/register/_discover.py”, line 112, in _register_plugin_by_type
register_snmp_section(plugin, location, validate=validate)
File “/omd/sites/Demo/lib/python3/cmk/base/api/agent_based/register/_discover.py”, line 146, in register_snmp_section
section_plugin = create_snmp_section_plugin(section, location, validate=validate)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/omd/sites/Demo/lib/python3/cmk/base/api/agent_based/register/section_plugins.py”, line 289, in create_snmp_section_plugin
_validate_detect_spec(snmp_section_spec.detect)
File “/omd/sites/Demo/lib/python3/cmk/base/api/agent_based/register/section_plugins.py”, line 177, in _validate_detect_spec
raise TypeError(
TypeError: value of ‘detect’ keywords third element must be a boolean: None
Hello everyone,
I am a beginner with Checkmk and I am currently trying to develop a custom SNMP check plugin using the cmk.agent_based.v2 API. When I run plugin detection, Checkmk fails to load the plugin and returns the following error.
My plugin code
#!/usr/bin/env python3
from cmk.agent_based.v2 import (
CheckPlugin,
startswith,
Service,
Result,
State,
SNMPSection,
SNMPTree,
all_of,
contains,
)
def parse_power(string_table):
data = {}
for idx, row in enumerate(string_table, start=1):
if len(row) < 3:
continue
data[str(idx)] = {
"status": row[0],
"ps_serial": row[1],
"switch_serial": row[2],
}
return data
def discover_power(section):
for item in section:
yield Service(item=item)
def check_power(item, section):
data = section[item]
status = data["status"]
ps_sn = data["ps_serial"]
sw_sn = data["switch_serial"]
if status == "Good":
yield Result(
state=State.OK,
summary=f"Power {item} OK | PSU SN: {ps_sn} | Switch SN: {sw_sn}",
)
else:
yield Result(
state=State.CRIT,
summary=f"Power {item} FAILED ({status}) | PSU SN: {ps_sn}",
)
snmp_section_power = SNMPSection(
name = "power_section",
parse_function = parse_power,
detect=all_of(
startswith(".1.3.6.1.2.1.1.1.0", "LANCOM"),
contains(".1.3.6.1.2.1.1.2.0", ".1.3.6.1.4.1.2356"),
),
fetch = [
SNMPTree(
base = '.1.3.6.1.4.1.2356.16.1.1.1.1',
oids = ['27.0','33.0','3.0'],
),
]
)
check_plugin_power = CheckPlugin(
name = "Power_Check",
sections = ["power_section"],
service_name = "Power Supply %s",
discovery_function = discover_power,
check_function = check_power,
)
SNMP information from the Switch
.1.3.6.1.2.1.1.1.0 LANCOM XS-5116QF --> SNMPv2-MIB::sysDescr.0
.1.3.6.1.2.1.1.2.0 .1.3.6.1.4.1.2356.16.8.5116 --> SNMPv2-MIB::sysObjectID.0
.
.
.
.1.3.6.1.2.1.16.1.1.1.1.26 26 --> RMON-MIB::etherStatsIndex.26
.1.3.6.1.2.1.16.1.1.1.1.27 27 --> RMON-MIB::etherStatsIndex.27
.1.3.6.1.2.1.16.1.1.1.1.28 28 --> RMON-MIB::etherStatsIndex.28
.1.3.6.1.2.1.16.1.1.1.1.29 29 --> RMON-MIB::etherStatsIndex.29
.1.3.6.1.2.1.16.1.1.1.1.30 30 --> RMON-MIB::etherStatsIndex.30
.1.3.6.1.2.1.16.1.1.1.1.31 31 --> RMON-MIB::etherStatsIndex.31
.1.3.6.1.2.1.16.1.1.1.1.32 32 --> RMON-MIB::etherStatsIndex.32
.1.3.6.1.2.1.16.1.1.1.1.33 33 --> RMON-MIB::etherStatsIndex.33
Any guidance would be greatly appreciated.