initial commit source files

This commit is contained in:
2025-04-05 11:34:44 +02:00
parent be36e53edf
commit 2e8733a1b3
13 changed files with 1075 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
#!/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
from cmk.rulesets.v1.form_specs import (
DictElement,
Dictionary,
migrate_to_password,
Password,
String,
validators,
)
from cmk.rulesets.v1.rule_specs import SpecialAgent, Topic
def _form_spec_special_agent_hal9002() -> Dictionary:
return Dictionary(
title=Title("HAL 9002 Server Information"),
help_text=Help("Checking HAL servers via API"),
elements={
"hostname": DictElement(
required=True,
parameter_form=String(
title=Title("Hostname"),
help_text=Help(
"Hostname of HAL server (bare FQDN or IP), mandatory, eg. hal9002.yourdomain.tld"
),
custom_validate=(validators.LengthInRange(min_value=1),),
),
),
"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),),
),
),
"password": DictElement(
required=True,
parameter_form=Password(
title=Title("Password"),
help_text=Help("Specify password, mandatory"),
custom_validate=(validators.LengthInRange(min_value=1),),
migrate=migrate_to_password,
),
),
},
)
rule_spec_hal9002 = SpecialAgent(
name="hal9002",
title=Title("HAL9002 connection parameters"),
topic=Topic.APPLICATIONS,
parameter_form=_form_spec_special_agent_hal9002,
)

View File

@@ -0,0 +1,48 @@
#!/user/bin/env python3
"""general parameter form for HAL9002"""
from cmk.rulesets.v1 import Help, Title
from cmk.rulesets.v1.form_specs import (
DictElement,
Dictionary,
ServiceState,
DefaultValue,
)
from cmk.agent_based.v2 import (
State,
)
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={
"state_if_update_is_available": DictElement(
required=True,
parameter_form=ServiceState(
title=Title("State if update is available"),
help_text=Help(
"State of service if an update is available, mandatory"
),
prefill=DefaultValue(value=State.WARN),
),
),
}
)
# name must begin with "rule_spec_", should refer to the used check plugin
# must be an instance of "CheckParameters"
rule_spec_hal9002_status = CheckParameters(
# "name" should be the same as the check plugin
name="hal9002_status",
# the title is shown in the GUI
title=Title("HAL9002 general parameters"),
# 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,47 @@
#!/user/bin/env python3
"""parameter form ruleset for HAL9002 storages"""
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={
"levels_hal_storages_rates": DictElement(
parameter_form=SimpleLevels(
title=Title("Levels for storage up and download rate"),
form_spec_template=Float(unit_symbol="MBytes/s"),
level_direction=LevelDirection.UPPER,
prefill_fixed_levels=DefaultValue(value=(200.0, 300.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_storages = CheckParameters(
# "name" should be the same as the check plugin
name="hal9002_storages",
# the title is shown in the GUI
title=Title("HAL9002 levels for storage upload/download"),
# 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=HostAndItemCondition(item_title=Title("Storage ID")),
)

View File

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