Nextcloud-CheckMK/nextcloud/rulesets/nextcloud_database_rules.py

46 lines
1.5 KiB
Python

#!/user/bin/env python3
"""parameter form ruleset for Nextcloud databases"""
from cmk.rulesets.v1 import Title
from cmk.rulesets.v1.form_specs import (
DefaultValue,
DictElement,
Dictionary,
Float,
LevelDirection,
SimpleLevels,
)
from cmk.rulesets.v1.rule_specs import HostCondition, CheckParameters, Topic
# function name should begin with an underscore to limit it's visibility
def _parameter_form():
return Dictionary(
elements={
"levels_database_opcache_hit_rate": DictElement(
parameter_form=SimpleLevels(
title=Title("Levels for database PHP op cache hit rate"),
form_spec_template=Float(),
level_direction=LevelDirection.LOWER,
prefill_fixed_levels=DefaultValue(value=(95.0, 85.0)),
),
required=True,
),
}
)
# name must begin with "rule_spec_", should refer to the used check plugin
# must be an instance of "CheckParameters"
rule_spec_nextcloud_database = CheckParameters(
# "name" should be the same as the check plugin
name="nextcloud_database",
# the title is shown in the GUI
title=Title("Levels for database PHP op cache hit rate"),
# 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(),
)