diff --git a/.werks/17516.md b/.werks/17516.md new file mode 100644 index 00000000000..d3455b8a216 --- /dev/null +++ b/.werks/17516.md @@ -0,0 +1,14 @@ +[//]: # (werk v2) +# Stormshield: Cluster Member: add missing ruleset + +key | value +---------- | --- +date | 2025-01-07T15:44:30+00:00 +version | 2.3.0p25 +class | fix +edition | cre +component | checks +level | 1 +compatible | yes + +The plugin _"Stormshield: Cluster Member"_ referred to a ruleset that did not exist. diff --git a/cmk/base/legacy_checks/stormshield_cluster_node.py b/cmk/base/legacy_checks/stormshield_cluster_node.py index 8a0be3161a1..47227961b30 100644 --- a/cmk/base/legacy_checks/stormshield_cluster_node.py +++ b/cmk/base/legacy_checks/stormshield_cluster_node.py @@ -10,8 +10,10 @@ from cmk.agent_based.v2 import ( all_of, any_of, + check_levels, equals, exists, + render, SNMPTree, startswith, StringTable, @@ -56,7 +58,6 @@ def check_stormshield_cluster_node(item, params, info): _uptime, ) in info: if item == index: - warn, crit = params["quality"] if online == "0": yield 2, "Member is %s" % online_mapping[online] else: @@ -77,12 +78,12 @@ def check_stormshield_cluster_node(item, params, info): forced_mapping[statusforced], ), ) - if int(quality) < crit: - yield 2, "Quality: %s" % quality - elif int(quality) < warn: - yield 1, "Quality: %s" % quality - else: - yield 0, "Quality: %s" % quality + yield from check_levels( + float(quality), + levels_lower=params["quality"], + label="Quality", + render_func=render.percent, + ) infotext = "Model: {}, Version: {}, Role: {}, Priority: {}, Serial: {}".format( model, @@ -116,6 +117,6 @@ def parse_stormshield_cluster_node(string_table: StringTable) -> StringTable: check_function=check_stormshield_cluster_node, check_ruleset_name="stormshield_quality", check_default_parameters={ - "quality": (80, 50), + "quality": ("fixed", (80.0, 50.0)), }, ) diff --git a/cmk/plugins/stormshield/rulesets/stormshield_quality.py b/cmk/plugins/stormshield/rulesets/stormshield_quality.py new file mode 100644 index 00000000000..a5e03fcabbb --- /dev/null +++ b/cmk/plugins/stormshield/rulesets/stormshield_quality.py @@ -0,0 +1,40 @@ +#!/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 Title +from cmk.rulesets.v1.form_specs import ( + DefaultValue, + DictElement, + Dictionary, + LevelDirection, + Percentage, + SimpleLevels, +) +from cmk.rulesets.v1.rule_specs import CheckParameters, HostAndItemCondition, Topic + + +def _parameter_form_quality() -> Dictionary: + return Dictionary( + elements={ + "quality": DictElement( + required=True, + parameter_form=SimpleLevels( + title=Title("Lower levels on quality"), + level_direction=LevelDirection.LOWER, + form_spec_template=Percentage(), + prefill_fixed_levels=DefaultValue(value=(80.0, 50.0)), + ), + ) + }, + ) + + +rule_spec_stormshield_quality = CheckParameters( + name="stormshield_quality", + topic=Topic.APPLICATIONS, + parameter_form=_parameter_form_quality, + title=Title("Stormshield quality"), + condition=HostAndItemCondition(item_title=Title("Node index")), +) diff --git a/tests/unit/cmk/gui/plugins/wato/check_parameters/test_plugin_vs_wato.py b/tests/unit/cmk/gui/plugins/wato/check_parameters/test_plugin_vs_wato.py index e00923dfcb2..cb76da9785a 100644 --- a/tests/unit/cmk/gui/plugins/wato/check_parameters/test_plugin_vs_wato.py +++ b/tests/unit/cmk/gui/plugins/wato/check_parameters/test_plugin_vs_wato.py @@ -277,7 +277,6 @@ class ErrorReporter: ("check", "nvidia_errors", "hw_errors"), ("check", "qlogic_fcport", "qlogic_fcport"), ("check", "sap_hana_proc", "sap_hana_proc"), - ("check", "stormshield_cluster_node", "stormshield_quality"), ("check", "stormshield_policy", "stormshield"), ("check", "stormshield_updates", "stormshield_updates"), ("check", "tsm_stagingpools", "tsm_stagingspools"),