initial upload of version 3.1.1 which uses the new plugin API

This commit is contained in:
2025-04-05 12:00:39 +02:00
parent 0152860b55
commit c0f4490b89
26 changed files with 1106 additions and 931 deletions

View File

@@ -0,0 +1,45 @@
#!/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(),
)

View File

@@ -0,0 +1,66 @@
#!/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(),
)

View File

@@ -0,0 +1,105 @@
#!/usr/bin/env python3
# pylint: disable=line-too-long, missing-module-docstring
from cmk.rulesets.v1 import Help, Label, Title
from cmk.rulesets.v1.form_specs import (
BooleanChoice,
DictElement,
Dictionary,
migrate_to_password,
Password,
String,
Integer,
validators,
InputHint,
)
from cmk.rulesets.v1.rule_specs import SpecialAgent, Topic
def _form_spec_special_agent_nextcloud() -> Dictionary:
return Dictionary(
title=Title("Nextcloud Server Information"),
help_text=Help("Checking Nextcloud servers via API"),
elements={
"hostname": DictElement(
required=True,
parameter_form=String(
title=Title("Hostname"),
help_text=Help(
"Hostname of Nextcloud server (bare FQDN or IP), mandatory, eg. nextcloud.yourdomain.tld"
),
custom_validate=(validators.LengthInRange(min_value=1),),
prefill=InputHint("nextcloud.yourdomain.tld"),
),
),
"username": DictElement(
required=True,
parameter_form=String(
title=Title("Username"),
help_text=Help("Username with administrative rights, mandatory"),
custom_validate=(validators.LengthInRange(min_value=1),),
prefill=InputHint("admin"),
),
),
"password": DictElement(
required=True,
parameter_form=Password(
title=Title("App Password"),
help_text=Help(
"Specify app password, mandatory, use Personal Settings|Security|Devices and Sessions within the NC UI to create one for the given user"
),
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 if not listening to HTTP(S), optional"
),
prefill=InputHint(8080),
custom_validate=(validators.NetworkPort(),),
),
),
"folder": DictElement(
required=False,
parameter_form=String(
title=Title("Folder"),
help_text=Help(
"Specify subfolder if your Nextcloud instance is not installed in the web root, no trailing/leading slashes, optional"
),
prefill=InputHint("nextcloud"),
),
),
"no_https": DictElement(
required=False,
parameter_form=BooleanChoice(
title=Title("Protocol handling"),
label=Label("Disable HTTPS"),
help_text=Help(
"Activate to disable encryption (not recommended), optional"
),
),
),
"no_cert_check": DictElement(
required=False,
parameter_form=BooleanChoice(
title=Title("Certificate handling"),
label=Label("Disable certificate validation"),
help_text=Help(
"Activate to disable certificate validation (not recommended), optional"
),
),
),
},
)
rule_spec_nextcloud = SpecialAgent(
name="nextcloud",
title=Title("Nextcloud connection parameters"),
topic=Topic.APPLICATIONS,
parameter_form=_form_spec_special_agent_nextcloud,
)

View File

@@ -0,0 +1,54 @@
#!/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")),
)