Hello,
I have a problem with one of my custom checks when I introduce a SingleChoice parameter form to an existing ruleset that has SimpleLevels parameters.
Rule spec code:
def _parameter_form_mysql_db_cluster():
return Dictionary(
elements={
"mysql_db_size": DictElement(
parameter_form=SimpleLevels[Integer](
title=Title(
"Levels for MySQL DB Size"),
form_spec_template=Integer(unit_symbol="GB"),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=InputHint(value=(100, 200)),
),
required=False,
),
"mysql_db_used": DictElement(
parameter_form=SimpleLevels[Integer](
title=Title(
"Levels for DB Space Used"),
form_spec_template=Integer(unit_symbol="GB"),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=InputHint(value=(400, 500)),
),
required=False,
),
"mysql_db_cpu": DictElement(
parameter_form=SimpleLevels[Integer](
title=Title(
"Levels for MySQL DB CPU Core Count"),
form_spec_template=Integer(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=InputHint(value=(2, 4)),
),
required=False,
),
"mysql_db_service_type": DictElement(
parameter_form=SingleChoice(
title=Title("Service License Type"),
form_spec_template=String(),
prefill=DefaultValue(value="LICENSE_INCLUDED"),
input_hint=InputHint(
value="Choose the license model for the MySQL DB"),
elements=[
SingleChoiceElement(title=Title('License Included'), name='LICENSE_INCLUDED'),
SingleChoiceElement(title=Title('None'), name='NONE'),
],
),
required=False,
),
}
)
rule_spec_mysql_db_cluster = CheckParameters(
name="mysql_db_cluster",
title=Title("MySQL DB Cluster"),
topic=Topic.GENERAL,
parameter_form=_parameter_form_mysql_db_cluster,
condition=HostAndItemCondition(
item_title=Title("MySQL DB Cluster"))
)
Following is the check code:
check_plugin_mysql_db_cluster = CheckPlugin(
name="mysql_db_cluster",
service_name="MySQL DB Cluster %s",
sections=["mysql_db_cluster"],
check_function=check_mysql_db_cluster,
discovery_function=discover_mysql_db_cluster,
check_default_parameters={'mysql_db_used': (
'fixed', (100, 200)),
'mysql_db_size': (
'fixed', (400, 500)),
'mysql_db_cpu': (
'fixed', (2, 4)),
'mysql_db_service_type': str('LICENSE_INCLUDED')},
check_ruleset_name="mysql_db_cluster",
)
When attempting to set the parameters on the check plugin the UI reports the error:
Internal error: static_checks:mysql_db_cluster
An internal error occured while processing your request. You can report this issue to the Checkmk team to help fixing this issue. Please open the crash report page and use the form for reporting the problem.
The exception on the crash report page shows:
KeyError (static_checks:mysql_db_cluster)
If I remove the ‘mysql_db_service_type’ parameter from the check_default_parameters and the ruleset it works as expected.
I think i’m missing something here either with the parameters being set in the check_default_parameters or the way that the parameter form is being constructed.
Any suggestions would be much appreciated.
Cheers - Mark