initial upload of version 2.1.0 which uses the new plugin API

This commit is contained in:
2025-04-05 11:47:59 +02:00
parent 358f84307c
commit cc2aaee908
34 changed files with 1204 additions and 1238 deletions

View File

@@ -0,0 +1,93 @@
#!/user/bin/env python3
"""parameter form ruleset for mailcow domains"""
from cmk.rulesets.v1 import Title
from cmk.rulesets.v1.form_specs import (
DefaultValue,
DictElement,
Dictionary,
LevelDirection,
SimpleLevels,
Percentage,
Integer,
)
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={
"levels_mailcow_domains_quota_used": DictElement(
parameter_form=SimpleLevels(
title=Title("Mailcow domains quota usage for storage"),
form_spec_template=Percentage(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(65.0, 85.0)),
),
required=True,
),
"levels_mailcow_domains_mailboxes_used": DictElement(
parameter_form=SimpleLevels(
title=Title("Mailcow domains mailboxes usage"),
form_spec_template=Percentage(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(65.0, 85.0)),
),
required=True,
),
"levels_mailcow_domains_aliases_used": DictElement(
parameter_form=SimpleLevels(
title=Title("Mailcow domains aliases usage"),
form_spec_template=Percentage(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(65.0, 85.0)),
),
required=True,
),
"levels_mailcow_domains_num_messages": DictElement(
parameter_form=SimpleLevels(
title=Title("Number of messages"),
form_spec_template=Integer(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(10_000, 25_000)),
),
required=True,
),
"levels_mailcow_domains_num_aliases": DictElement(
parameter_form=SimpleLevels(
title=Title("Number of configured aliases"),
form_spec_template=Integer(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(100, 250)),
),
required=True,
),
"levels_mailcow_domains_num_mailboxes": DictElement(
parameter_form=SimpleLevels(
title=Title("Number of configured mailboxes"),
form_spec_template=Integer(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(100, 250)),
),
required=True,
),
}
)
# name must begin with "rule_spec_", should refer to the used check plugin
# must be an instance of "CheckParameters"
rule_spec_mailcow_domains = CheckParameters(
# "name" should be the same as the check plugin
name="mailcow_domains",
# the title is shown in the GUI
title=Title("Mailcow domain levels"),
# this ruleset can be found under Setup|Service monitoring rules|Various
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("Domain")),
)

View File

@@ -0,0 +1,65 @@
#!/usr/bin/env python3
"""
defines the form for typing in all needed levels
regarding number of domains, mailboxes and global message count
"""
from cmk.rulesets.v1 import Help, Title
from cmk.rulesets.v1.form_specs import (
DictElement,
Dictionary,
SimpleLevels,
LevelDirection,
DefaultValue,
Integer,
)
from cmk.rulesets.v1.rule_specs import (
CheckParameters,
Topic,
HostCondition,
)
def _parameter_form() -> Dictionary:
return Dictionary(
title=Title("Levels for global Mailcow information"),
help_text=Help("Checking Mailcow systems via API"),
elements={
"levels_num_domains": DictElement(
parameter_form=SimpleLevels(
title=Title("Levels for number of email domains"),
form_spec_template=Integer(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(100, 200)),
),
required=True,
),
"levels_num_mailboxes": DictElement(
parameter_form=SimpleLevels(
title=Title("Levels for number of mailboxes"),
form_spec_template=Integer(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(500, 1000)),
),
required=True,
),
"levels_num_global_messages": DictElement(
parameter_form=SimpleLevels(
title=Title("Levels for number of messages"),
form_spec_template=Integer(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(100_000, 250_000)),
),
required=True,
),
},
)
rule_spec_mailcow_info = CheckParameters(
name="mailcow_info",
title=Title("Mailcow global levels"),
topic=Topic.APPLICATIONS,
parameter_form=_parameter_form,
condition=HostCondition(),
)

View File

@@ -0,0 +1,57 @@
#!/user/bin/env python3
"""parameter form ruleset for mailcow domains"""
from cmk.rulesets.v1 import Title
from cmk.rulesets.v1.form_specs import (
DefaultValue,
DictElement,
Dictionary,
LevelDirection,
SimpleLevels,
Percentage,
Integer,
)
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={
"levels_mailcow_mailboxes_quota_used": DictElement(
parameter_form=SimpleLevels(
title=Title("Mailcow mailbox quota usage for storage"),
form_spec_template=Percentage(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(65.0, 85.0)),
),
required=True,
),
"levels_mailcow_mailboxes_num_messages": DictElement(
parameter_form=SimpleLevels(
title=Title("Number of messages in mailbox"),
form_spec_template=Integer(),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(1000, 2500)),
),
required=True,
),
}
)
# name must begin with "rule_spec_", should refer to the used check plugin
# must be an instance of "CheckParameters"
rule_spec_mailcow_mailboxes = CheckParameters(
# "name" should be the same as the check plugin
name="mailcow_mailboxes",
# the title is shown in the GUI
title=Title("Mailcow mailbox levels"),
# this ruleset can be found under Setup|Service monitoring rules|Various
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("Mailbox")),
)

View File

@@ -0,0 +1,98 @@
#!/usr/bin/env python3
# pylint: disable=line-too-long
"""defines the form for typing in all needed HAL9002 parameters"""
from cmk.rulesets.v1 import Help, Title, Label
from cmk.rulesets.v1.form_specs import (
DictElement,
Dictionary,
String,
validators,
BooleanChoice,
Integer,
Password,
migrate_to_password,
InputHint,
DefaultValue,
)
from cmk.rulesets.v1.rule_specs import SpecialAgent, Topic
def _form_spec_special_agent_mailcow() -> Dictionary:
return Dictionary(
title=Title("Mailcow Server Information"),
help_text=Help("Checking Mailcow systems via API"),
elements={
"hostname": DictElement(
required=True,
parameter_form=String(
title=Title("Hostname"),
help_text=Help(
"Hostname of Mailcow server (bare FQDN or IP), mandatory, eg. mailcow.yourdomain.tld"
),
custom_validate=(validators.LengthInRange(min_value=1),),
prefill=InputHint("mailcow.yourdomain.tld"),
),
),
"apikey": DictElement(
required=True,
parameter_form=Password(
title=Title("API key"),
help_text=Help("Specify API key, mandatory"),
custom_validate=(validators.LengthInRange(min_value=1),),
migrate=migrate_to_password,
),
),
"port": DictElement(
required=False,
parameter_form=Integer(
title=Title("Port"),
help_text=Help(
"Specify port the Mailcow system ist listening on, mandatory"
),
prefill=DefaultValue(443),
custom_validate=(validators.NetworkPort(),),
),
),
"check_version": DictElement(
required=False,
parameter_form=BooleanChoice(
title=Title("Check Mailcow version"),
help_text=Help(
"Activate to check version of running Mailcow against actual Github version, optional"
),
label=Label(
"Enable version check (requires access to Github internet site)"
),
),
),
"no_https": DictElement(
required=False,
parameter_form=BooleanChoice(
title=Title("Disable HTTPS"),
help_text=Help(
"Activate to disable encryption (not recommended), optional"
),
label=Label("Disable HTTPS"),
),
),
"no_cert_check": DictElement(
required=False,
parameter_form=BooleanChoice(
title=Title("Disable certificate validation"),
help_text=Help(
"Activate to disable certificate validation (not recommended), optional"
),
label=Label("Disable certificate validation"),
),
),
},
)
rule_spec_mailcow = SpecialAgent(
name="mailcow",
title=Title("Mailcow connection parameters"),
topic=Topic.APPLICATIONS,
parameter_form=_form_spec_special_agent_mailcow,
)