Hi,
I’m starting to look at writing (snmp based) plugins. This is my code so far.
based upon Writing your own check plug-ins
#!/usr/bin/env python3
# -*- encoding: utf-8; py-indent-offset: 4 -*-
from cmk.base.plugins.agent_based.agent_based_api.v1 import *
register.snmp_section(
name='MyTest_temp',
detect=exists('.1.3.6.1.4.1.14988.1.1.3.10.0'),
fetch=SNMPTree(
base='.1.3.6.1.4.1.14988.1.1.3',
oids=[
'10',
],
),
)
def discovery_MyTest_temp(section):
if section:
yield Service()
def check_MyTest_temp(params, section):
if section:
temp = str(float(section[0][0])/10)
yield Result(state=State.OK, summary=f"Internal Temp {temp}", details=str( params ) )
return
register.check_plugin(
name='MyTest_temp',
service_name='MyTest Temperature',
discovery_function=discovery_MyTest_temp,
check_function=check_MyTest_temp,
check_default_parameters={},
check_ruleset_name="hw_temperature",
)
And it mostly works as expected. The point is the params in the check function is always empty.
Looking at “/lib/python3/cmk/gui/plugins/wato/check_parameters/hw_temperature_single.py” i’d expected the default values from that file to be shown.
Changing the line to
check_default_parameters={"warning at": 30, "critical at": 40 },
or
check_default_parameters={"warning_at": 30, "critical_at": 40 },
results in “Invalid parameter {‘warning at’: 30, ‘critical at’: 40}: 0” when checking the parameters in the gui.
Looks like i’m not handling that part very well. Can someone point me in the right direction?