55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
#!/user/bin/env python3
|
|
"""parameter form ruleset for Nextcloud users"""
|
|
|
|
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 HostAndItemCondition, CheckParameters, Topic
|
|
|
|
|
|
# function name should begin with an underscore to limit it's visibility
|
|
def _parameter_form():
|
|
return Dictionary(
|
|
elements={
|
|
"levels_users_quota_used": DictElement(
|
|
parameter_form=SimpleLevels(
|
|
title=Title("Levels for quota usage of users"),
|
|
form_spec_template=Float(unit_symbol="%"),
|
|
level_direction=LevelDirection.UPPER,
|
|
prefill_fixed_levels=DefaultValue(value=(65.0, 85.0)),
|
|
),
|
|
required=True,
|
|
),
|
|
"levels_users_free_space": DictElement(
|
|
parameter_form=SimpleLevels(
|
|
title=Title("Levels for free disk space of users"),
|
|
form_spec_template=Float(unit_symbol="MBytes"),
|
|
level_direction=LevelDirection.LOWER,
|
|
prefill_fixed_levels=DefaultValue(value=(256.0, 128.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_users = CheckParameters(
|
|
# "name" should be the same as the check plugin
|
|
name="nextcloud_users",
|
|
# the title is shown in the GUI
|
|
title=Title("Levels for Nextcloud users"),
|
|
# 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=HostAndItemCondition(item_title=Title("User ID")),
|
|
)
|