HAL9002-CheckMK/hal9002/rulesets/rs_hal9002_users.py

48 lines
1.6 KiB
Python

#!/user/bin/env python3
"""parameter form ruleset for HAL9002 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 CheckParameters, HostAndItemCondition, Topic
# function name should begin with an underscore to limit it's visibility
def _parameter_form():
return Dictionary(
elements={
"quota_used_percent": DictElement(
parameter_form=SimpleLevels(
title=Title("Percentage thresholds for storage quota used"),
form_spec_template=Float(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(80.0, 90.0)),
),
required=True,
),
}
)
# name must begin with "rule_spec_", should refer to the used check plugin
# must be an instance of "CheckParameters"
rule_spec_hal9002_users = CheckParameters(
# "name" should be the same as the check plugin
name="hal9002_users",
# the title is shown in the GUI
title=Title("HAL9002 levels for user storage quota"),
# 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 users (item)
condition=HostAndItemCondition(item_title=Title("User ID")),
)