#!/user/bin/env python3 """UDP components parameter form for Traefik""" from cmk.rulesets.v1 import Title, Help from cmk.rulesets.v1.form_specs import ( DictElement, Dictionary, SimpleLevels, DefaultValue, Integer, LevelDirection, Float, ) from cmk.rulesets.v1.rule_specs import CheckParameters, Topic, HostCondition # function name should begin with an underscore to limit it's visibility def _parameter_form(): return Dictionary( elements={ "levels_traefik_min_udp_routers": DictElement( parameter_form=SimpleLevels( title=Title("Levels for minimum number of UDP routers"), help_text=Help( "Define the levels for the minimum number of UDP routers" ), form_spec_template=Integer(unit_symbol=""), level_direction=LevelDirection.LOWER, prefill_fixed_levels=DefaultValue(value=(0, 0)), ), required=True, ), "levels_traefik_max_udp_routers": DictElement( parameter_form=SimpleLevels( title=Title("Levels for maximum number of UDP routers"), help_text=Help( "Define the levels for the maximum number of UDP routers" ), form_spec_template=Integer(unit_symbol=""), level_direction=LevelDirection.UPPER, prefill_fixed_levels=DefaultValue(value=(25, 50)), ), required=True, ), "levels_traefik_min_udp_services": DictElement( parameter_form=SimpleLevels( title=Title("Levels for minimum number of UDP services"), help_text=Help( "Define the levels for the minimum number of UDP services" ), form_spec_template=Integer(unit_symbol=""), level_direction=LevelDirection.LOWER, prefill_fixed_levels=DefaultValue(value=(0, 0)), ), required=True, ), "levels_traefik_max_udp_services": DictElement( parameter_form=SimpleLevels( title=Title("Levels for maximum number of UDP services"), help_text=Help( "Define the levels for the maximum number of UDP services" ), form_spec_template=Integer(unit_symbol=""), level_direction=LevelDirection.UPPER, prefill_fixed_levels=DefaultValue(value=(25, 50)), ), required=True, ), "levels_traefik_udp_components_not_ok": DictElement( parameter_form=SimpleLevels( title=Title("Levels for percentage of not OK UDP components"), help_text=Help( "Define the levels for the maximum number of UDP components in not OK state" ), form_spec_template=Float(unit_symbol="%"), level_direction=LevelDirection.UPPER, prefill_fixed_levels=DefaultValue(value=(0.5, 1.0)), ), required=True, ), } ) # name must begin with "rule_spec_", should refer to the used check plugin # must be an instance of "CheckParameters" rule_spec_traefik_udp_components = CheckParameters( # "name" should be the same as the check plugin name="traefik_udp_components", # the title is shown in the GUI title=Title("Traefik UDP components parameters"), # this ruleset can be found under Setup|Service monitoring rules|Applications... topic=Topic.APPLICATIONS, # define the name of the function which creates the GUI elements parameter_form=_parameter_form, condition=HostCondition(), )