Check_ruleset_name and default parameters


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 *


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 ) )

    service_name='MyTest 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/” 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 },


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?

There is a utility function check_temperature which uses the ruleset name “temperature”. You should use that one.

Have a look at $OMD_ROOT/lib/check_mk/base/plugins/agent_based/utils/

Import it into your check plugin with
from .utils.temperature import check_temperature

Use it in the check function with
yield from check_temperature(…)

Thanks, will look at those. (By the way, I simply took temperature metric just for learning the plugins)

I guess this is because of a not matching WATO rule set. So no real error, but “only” a incompatible WATO function. hw_temperature returns a Tuple, not a Dictionary as in your check_default_parameters definition.

When offering a tuple, it throws an error stating it wants a dict

File "/omd/sites/officelab/lib/python3/cmk/base/api/agent_based/register/", line 204, in validate_default_parameters  raise TypeError("default %s parameters must be dict" % (params_type,))

hw_temperature is an old WATO rule set. The new API expects a dictionary at this point. You should remove hw_temperature from your check, and write your own rule set (that returns a dictionary) or in case of a temparature sensor go with the check_temperature function as @r.sander said, and use temperature as rule set, with the correct parmeters of curse :wink:

1 Like