Nextcloud-CheckMK/nextcloud/rulesets/nextcloud_info_rules.py

67 lines
2.4 KiB
Python

#!/user/bin/env python3
"""parameter form ruleset for Nextcloud systems"""
from cmk.rulesets.v1 import Title
from cmk.rulesets.v1.form_specs import (
DefaultValue,
DictElement,
Dictionary,
Float,
LevelDirection,
SimpleLevels,
Integer,
)
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_apps_with_updates_available": DictElement(
parameter_form=SimpleLevels(
title=Title("Number of installed apps with updates available"),
form_spec_template=Integer(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(1, 2)),
),
required=True,
),
"levels_free_space": DictElement(
parameter_form=SimpleLevels(
title=Title("Levels for free disk space overall"),
form_spec_template=Float(unit_symbol="GBytes"),
level_direction=LevelDirection.LOWER,
prefill_fixed_levels=DefaultValue(value=(8.0, 4.0)),
),
required=True,
),
"levels_number_of_files": DictElement(
parameter_form=SimpleLevels(
title=Title("Number of files overall"),
form_spec_template=Integer(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(100_000, 250_000)),
),
required=True,
),
}
)
# name must begin with "rule_spec_", should refer to the used check plugin
# must be an instance of "CheckParameters"
rule_spec_nextcloud_info = CheckParameters(
# "name" should be the same as the check plugin
name="nextcloud_info",
# the title is shown in the GUI
title=Title("Various parameters for Nextcloud systems"),
# 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,
# define the label in the GUI where you can restrict the
# settings to one or mor specific storages (item)
condition=HostCondition(),
)