-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Marked the old ruleset as deprecated and replaced it with new metric-specific ones. Created an update action to migrate rulesets. CMK-20829 Change-Id: I7fcb41007e85a57b7ac72372a45c92adff170d1b
- Loading branch information
1 parent
28dae44
commit f2dc191
Showing
12 changed files
with
537 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2025 Checkmk GmbH - License: GNU General Public License v2 | ||
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and | ||
# conditions defined in the file COPYING, which is part of this source code package. | ||
from cmk.rulesets.v1 import Help, Title | ||
from cmk.rulesets.v1.form_specs import ( | ||
DefaultValue, | ||
DictElement, | ||
Dictionary, | ||
Float, | ||
LevelDirection, | ||
migrate_to_float_simple_levels, | ||
SimpleLevels, | ||
) | ||
from cmk.rulesets.v1.rule_specs import CheckParameters, HostAndItemCondition, Topic | ||
|
||
|
||
def _make_form() -> Dictionary: | ||
return Dictionary( | ||
help_text=Help("This ruleset allows you to configure levels for the database CPU usage"), | ||
elements={ | ||
"cpu_percent": DictElement( | ||
required=True, | ||
parameter_form=SimpleLevels( | ||
title=Title("CPU"), | ||
level_direction=LevelDirection.UPPER, | ||
form_spec_template=Float(), | ||
migrate=migrate_to_float_simple_levels, | ||
prefill_fixed_levels=DefaultValue((85.0, 95.0)), | ||
), | ||
) | ||
}, | ||
) | ||
|
||
|
||
rule_spec_azure_databases_cpu = CheckParameters( | ||
name="azure_databases_cpu", | ||
title=Title("Azure SQL database CPU usage"), | ||
topic=Topic.APPLICATIONS, | ||
parameter_form=_make_form, | ||
condition=HostAndItemCondition(item_title=Title("Database name")), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2025 Checkmk GmbH - License: GNU General Public License v2 | ||
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and | ||
# conditions defined in the file COPYING, which is part of this source code package. | ||
from cmk.rulesets.v1 import Help, Title | ||
from cmk.rulesets.v1.form_specs import ( | ||
DictElement, | ||
Dictionary, | ||
Float, | ||
InputHint, | ||
LevelDirection, | ||
migrate_to_integer_simple_levels, | ||
SimpleLevels, | ||
) | ||
from cmk.rulesets.v1.rule_specs import CheckParameters, HostAndItemCondition, Topic | ||
|
||
|
||
def _make_form() -> Dictionary: | ||
return Dictionary( | ||
help_text=Help( | ||
"This ruleset allows you to configure levels for the deadlocks in the database" | ||
), | ||
elements={ | ||
"deadlocks": DictElement( | ||
required=True, | ||
parameter_form=SimpleLevels( | ||
title=Title("Deadlocks"), | ||
level_direction=LevelDirection.UPPER, | ||
form_spec_template=Float(), | ||
migrate=migrate_to_integer_simple_levels, | ||
prefill_fixed_levels=InputHint((10, 100)), # No default defined previously | ||
), | ||
) | ||
}, | ||
) | ||
|
||
|
||
rule_spec_azure_databases_deadlock = CheckParameters( | ||
name="azure_databases_deadlock", | ||
title=Title("Azure SQL database deadlocks"), | ||
topic=Topic.APPLICATIONS, | ||
parameter_form=_make_form, | ||
condition=HostAndItemCondition(item_title=Title("Database name")), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2025 Checkmk GmbH - License: GNU General Public License v2 | ||
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and | ||
# conditions defined in the file COPYING, which is part of this source code package. | ||
from cmk.rulesets.v1 import Help, Title | ||
from cmk.rulesets.v1.form_specs import ( | ||
DefaultValue, | ||
DictElement, | ||
Dictionary, | ||
Float, | ||
LevelDirection, | ||
migrate_to_float_simple_levels, | ||
SimpleLevels, | ||
) | ||
from cmk.rulesets.v1.rule_specs import CheckParameters, HostAndItemCondition, Topic | ||
|
||
|
||
def _make_form() -> Dictionary: | ||
return Dictionary( | ||
help_text=Help("This ruleset allows you to configure levels for the database throughput"), | ||
elements={ | ||
"dtu_percent": DictElement( | ||
required=True, | ||
parameter_form=SimpleLevels( | ||
title=Title("Database throughput units in percent"), | ||
level_direction=LevelDirection.UPPER, | ||
form_spec_template=Float(), | ||
migrate=migrate_to_float_simple_levels, | ||
prefill_fixed_levels=DefaultValue((40.0, 50.0)), | ||
), | ||
) | ||
}, | ||
) | ||
|
||
|
||
rule_spec_azure_databases_dtu = CheckParameters( | ||
name="azure_databases_dtu", | ||
title=Title("Azure SQL database throughput"), | ||
topic=Topic.APPLICATIONS, | ||
parameter_form=_make_form, | ||
condition=HostAndItemCondition(item_title=Title("Database name")), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2025 Checkmk GmbH - License: GNU General Public License v2 | ||
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and | ||
# conditions defined in the file COPYING, which is part of this source code package. | ||
from cmk.rulesets.v1 import Help, Title | ||
from cmk.rulesets.v1.form_specs import ( | ||
DefaultValue, | ||
DictElement, | ||
Dictionary, | ||
Float, | ||
LevelDirection, | ||
migrate_to_float_simple_levels, | ||
SimpleLevels, | ||
) | ||
from cmk.rulesets.v1.rule_specs import CheckParameters, HostAndItemCondition, Topic | ||
|
||
|
||
def _make_form() -> Dictionary: | ||
return Dictionary( | ||
help_text=Help( | ||
"This ruleset allows you to configure levels for the used storage space in percent" | ||
), | ||
elements={ | ||
"storage_percent": DictElement( | ||
required=True, | ||
parameter_form=SimpleLevels( | ||
title=Title("Used storage"), | ||
level_direction=LevelDirection.UPPER, | ||
form_spec_template=Float(unit_symbol="%"), | ||
migrate=migrate_to_float_simple_levels, | ||
prefill_fixed_levels=DefaultValue((85.0, 95.0)), | ||
), | ||
) | ||
}, | ||
) | ||
|
||
|
||
rule_spec_azure_databases_storage = CheckParameters( | ||
name="azure_databases_storage", | ||
title=Title("Azure SQL database storage"), | ||
topic=Topic.APPLICATIONS, | ||
parameter_form=_make_form, | ||
condition=HostAndItemCondition(item_title=Title("Database name")), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2025 Checkmk GmbH - License: GNU General Public License v2 | ||
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and | ||
# conditions defined in the file COPYING, which is part of this source code package. | ||
from logging import Logger | ||
|
||
from cmk.gui.watolib.rulesets import AllRulesets | ||
|
||
from cmk.update_config.plugins.lib.azure_databases import AzureDatabaseMigration | ||
from cmk.update_config.registry import update_action_registry, UpdateAction | ||
|
||
|
||
class MigrateAzureDatabases(UpdateAction): | ||
def __call__(self, logger: Logger) -> None: | ||
migration = AzureDatabaseMigration( | ||
logger=logger, all_rulesets=AllRulesets.load_all_rulesets() | ||
) | ||
for error in migration: | ||
pass | ||
migration.all_rulesets.save() | ||
|
||
|
||
update_action_registry.register( | ||
# Sort index is chosen such that this action is executed before "rulesets". | ||
# But this is only a weak requirement. | ||
MigrateAzureDatabases(name="azure-databases", title="Migrate Azure Databases", sort_index=29) | ||
) |
Oops, something went wrong.