CMK version:
2.1.0p33
OS version:
Ubuntu 20.04.6
Error message:
TypeError: snmp_section() got an unexpected keyword argument ‘parse_funtion’
Output of “cmk --debug -vvn hostname”: (If it is a problem with checks or plugins)
OMD[nagios]:~/local/lib/check_mk/base/plugins/agent_based$ cmk --debug -vvn nexans-switch01
Trying to acquire lock on /omd/sites/nagios/var/check_mk/crashes/base/19831ff4-52e9-11ee-ad70-55f85aa5a838/crash.info
Got lock on /omd/sites/nagios/var/check_mk/crashes/base/19831ff4-52e9-11ee-ad70-55f85aa5a838/crash.info
Releasing lock on /omd/sites/nagios/var/check_mk/crashes/base/19831ff4-52e9-11ee-ad70-55f85aa5a838/crash.info
Released lock on /omd/sites/nagios/var/check_mk/crashes/base/19831ff4-52e9-11ee-ad70-55f85aa5a838/crash.info
Traceback (most recent call last):
File “/omd/sites/nagios/bin/cmk”, line 79, in
errors = config.load_all_agent_based_plugins(check_api.get_check_api_context)
File “/omd/sites/nagios/lib/python3/cmk/base/config.py”, line 1522, in load_all_agent_based_plugins
errors = agent_based_register.load_all_plugins()
File “/omd/sites/nagios/lib/python3/cmk/base/api/agent_based/register/init.py”, line 50, in load_all_plugins
raise exception
File “/omd/sites/nagios/lib/python3/cmk/utils/plugin_loader.py”, line 48, in load_plugins_with_exceptions
importlib.import_module(full_name)
File “/omd/sites/nagios/lib/python3.9/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1030, in _gcd_import
File “”, line 1007, in _find_and_load
File “”, line 986, in _find_and_load_unlocked
File “”, line 680, in _load_unlocked
File “”, line 850, in exec_module
File “”, line 228, in _call_with_frames_removed
File “/omd/sites/nagios/local/lib/python3/cmk/base/plugins/agent_based/nexans_temp.py”, line 78, in
register.snmp_section(
TypeError: snmp_section() got an unexpected keyword argument ‘parse_funtion’
Hi, I am currently trying to write some custom snmp checks for our Nexans Switch hosts. I tried following the official documentation for the development of snmp plugins aswell as reading up on some examples, fellow CheckMK users created.
The issue is I am getting the error mentioned above. Which I don’t really understand, since I checked the source code and for the snmp_section there is a keyword ‘parse_function’. However this is my whole plugin, located in the agent_based directory of my site:
#!/usr/bin/env python3
from dataclasses import dataclass
from typing import Optional
from cmk.base.plugins.agent_based.agent_based_api.v1.type_defs import (
DiscoveryResult,
CheckResult,
StringTable,
)
from cmk.base.plugins.agent_based.agent_based_api.v1 import (
register,
Service,
Result,
SNMPTree,
contains,
State,
check_levels,
)
@dataclass
class NexansTemp:
infoTemperature: int
highlimit: int
def parse_nexans_temp(string_table: StringTable) -> Optional[NexansTemp]:
try:
infoTemperature, highlimit = string_table[0]
except IndexError:
return
infoTemperature = int(infoTemperature)
highlimit = int(highlimit)
return NexansTemp(
infoTemperature=infoTemperature,
highlimit=highlimit,
)
def discovery_nexans_temp(section: NexansTemp) -> DiscoveryResult:
yield Service()
def check_nexans_temp(params, section: NexansTemp) -> CheckResult:
yield from check_levels(
value=section.infoTemperature,
label='Temperature',
levels_upper=params['levels_upper'],
levels_lower=params['level_lower'],
render_func=lambda v: f'{v}°C',
metric_name='temp',
boundaries=(0,100),
)
yield Result(state=State.OK,
notice=f'Lower/upper levels reported by the device: 5°C/{section.highlimit}°C')
register.snmp_section(
name='nexans_temp',
parse_funtion=parse_nexans_temp,
fetch=SNMPTree(
base='.1.3.6.1.4.1.266.20.1',
oids=[
'12', # temp
'13', # max temp
]
),
detect=contains('.1.3.6.1.4.1.266.20.1.1', 'GigaSwitch'),
)
register.check_plugin(
name='nexans_temp',
service_name='Temperature',
discovery_function=discovery_nexans_temp,
check_function=check_nexans_temp,
check_default_parameters={'levels_upper': (65, 70), 'levels_lower': (7, 5)},
check_ruleset_name='nexans_temp',
)
I hope somebody can help me understand, since I am kinda lost here.
Thanks in advance & have a great day @everyone reading.
Best regards,
Constantin Bettels