From 87c0884942a8be6199587993484517fa082eba0a Mon Sep 17 00:00:00 2001 From: Moritz Kiemer Date: Wed, 8 Jan 2025 10:34:59 +0100 Subject: [PATCH] plugins & rulesets: remove references to non-existing rulesets Change-Id: I08c912e5f1016b12482ba04ee9ef0ef9a1b2936f --- cmk/base/legacy_checks/brocade_tm.py | 25 ++++++++++--------- .../legacy_checks/mongodb_replication_info.py | 3 +-- .../legacy_checks/moxa_iologik_register.py | 3 +-- cmk/base/legacy_checks/qlogic_fcport.py | 1 - cmk/base/legacy_checks/stormshield_policy.py | 3 +-- cmk/base/legacy_checks/stormshield_updates.py | 24 +++++++++--------- .../check_parameters/test_plugin_vs_wato.py | 24 ++++++++++-------- 7 files changed, 41 insertions(+), 42 deletions(-) diff --git a/cmk/base/legacy_checks/brocade_tm.py b/cmk/base/legacy_checks/brocade_tm.py index 76361cb2fde..4cc3b089e8e 100644 --- a/cmk/base/legacy_checks/brocade_tm.py +++ b/cmk/base/legacy_checks/brocade_tm.py @@ -16,6 +16,17 @@ from cmk.agent_based.v2 import get_rate, get_value_store, SNMPTree, StringTable from cmk.plugins.lib.brocade import DETECT_MLX +LEVELS = { + "brcdTMStatsTotalIngressPktsCnt": (1000, 10000), + "brcdTMStatsIngressEnqueuePkts": (1000, 10000), + "brcdTMStatsEgressEnqueuePkts": (1000, 10000), + "brcdTMStatsIngressDequeuePkts": (1000, 10000), + "brcdTMStatsIngressTotalQDiscardPkts": (1000, 10000), + "brcdTMStatsIngressOldestDiscardPkts": (1000, 10000), + "brcdTMStatsEgressDiscardPkts": (1000, 10000), +} + + check_info = {} @@ -26,7 +37,7 @@ def inventory_brocade_tm(info): return inventory -def check_brocade_tm(item, params, info): +def check_brocade_tm(item, _no_params, info): for line in info: if line[0] == item: tm = {} @@ -50,7 +61,7 @@ def check_brocade_tm(item, params, info): value_store, f"{name}.{item}", now, int(counter), raise_overflow=True ) - warn, crit = params["brcdTMStats" + name] + warn, crit = LEVELS["brcdTMStats" + name] if re.search("Discard", name): if rate > crit: state = 2 @@ -88,14 +99,4 @@ def parse_brocade_tm(string_table: StringTable) -> StringTable: service_name="TM %s", discovery_function=inventory_brocade_tm, check_function=check_brocade_tm, - check_ruleset_name="brocade_tm", - check_default_parameters={ - "brcdTMStatsTotalIngressPktsCnt": (1000, 10000), - "brcdTMStatsIngressEnqueuePkts": (1000, 10000), - "brcdTMStatsEgressEnqueuePkts": (1000, 10000), - "brcdTMStatsIngressDequeuePkts": (1000, 10000), - "brcdTMStatsIngressTotalQDiscardPkts": (1000, 10000), - "brcdTMStatsIngressOldestDiscardPkts": (1000, 10000), - "brcdTMStatsEgressDiscardPkts": (1000, 10000), - }, ) diff --git a/cmk/base/legacy_checks/mongodb_replication_info.py b/cmk/base/legacy_checks/mongodb_replication_info.py index 723d4b0d278..31a494e27a4 100644 --- a/cmk/base/legacy_checks/mongodb_replication_info.py +++ b/cmk/base/legacy_checks/mongodb_replication_info.py @@ -40,7 +40,7 @@ def discover_mongodb_replication_info(section: Section) -> Iterable[tuple[None, yield None, {} -def check_mongodb_replication_info(item, params, info_dict): +def check_mongodb_replication_info(_no_item, _no_params, info_dict): """ just outputting long output and performance data for now. :param item: @@ -146,5 +146,4 @@ def _get_as_int(data, key): service_name="MongoDB Replication Info", discovery_function=discover_mongodb_replication_info, check_function=check_mongodb_replication_info, - check_ruleset_name="mongodb_replication_info", ) diff --git a/cmk/base/legacy_checks/moxa_iologik_register.py b/cmk/base/legacy_checks/moxa_iologik_register.py index b2a68325976..97940aa1c7c 100644 --- a/cmk/base/legacy_checks/moxa_iologik_register.py +++ b/cmk/base/legacy_checks/moxa_iologik_register.py @@ -20,7 +20,7 @@ def inventory_iologik_register(info): return inventory -def check_iologik_register(item, params, info): +def check_iologik_register(item, _no_params, info): for line in info: if line[0] == item: if int(line[2]) in range(0, 2): @@ -48,7 +48,6 @@ def parse_moxa_iologik_register(string_table: StringTable) -> StringTable: service_name="Moxa Register", discovery_function=inventory_iologik_register, check_function=check_iologik_register, - check_ruleset_name="iologik_register", ) # DIOEntry diff --git a/cmk/base/legacy_checks/qlogic_fcport.py b/cmk/base/legacy_checks/qlogic_fcport.py index 7b1017ac9a3..988ec258a45 100644 --- a/cmk/base/legacy_checks/qlogic_fcport.py +++ b/cmk/base/legacy_checks/qlogic_fcport.py @@ -299,5 +299,4 @@ def parse_qlogic_fcport(string_table: StringTable) -> StringTable: service_name="FC Port %s", discovery_function=inventory_qlogic_fcport, check_function=check_qlogic_fcport, - check_ruleset_name="qlogic_fcport", ) diff --git a/cmk/base/legacy_checks/stormshield_policy.py b/cmk/base/legacy_checks/stormshield_policy.py index e62c898e0ba..1387876cf44 100644 --- a/cmk/base/legacy_checks/stormshield_policy.py +++ b/cmk/base/legacy_checks/stormshield_policy.py @@ -16,7 +16,7 @@ def inventory_stormshield_policy(info): yield (line[0], None) -def check_stormshield_policy(item, params, info): +def check_stormshield_policy(item, _no_params, info): sync_status_mapping = { "1": "synced", "2": "not synced", @@ -49,5 +49,4 @@ def parse_stormshield_policy(string_table: StringTable) -> StringTable: service_name="Policy %s", discovery_function=inventory_stormshield_policy, check_function=check_stormshield_policy, - check_ruleset_name="stormshield", ) diff --git a/cmk/base/legacy_checks/stormshield_updates.py b/cmk/base/legacy_checks/stormshield_updates.py index c7a84a8ebab..a5bfa3b341f 100644 --- a/cmk/base/legacy_checks/stormshield_updates.py +++ b/cmk/base/legacy_checks/stormshield_updates.py @@ -10,6 +10,16 @@ check_info = {} +STATE_MAP = { + "Not Available": 1, + "Broken": 2, + "Uptodate": 0, + "Disabled": 1, + "Never started": 0, + "Running": 0, + "Failed": 2, +} + def inventory_stormshield_updates(info): for subsystem, state, lastrun in info: @@ -19,13 +29,13 @@ def inventory_stormshield_updates(info): yield subsystem, {} -def check_stormshield_updates(item, params, info): +def check_stormshield_updates(item, _no_params, info): for subsystem, state, lastrun in info: if item == subsystem: if lastrun == "": lastrun = "Never" infotext = f"Subsystem {subsystem} is {state}, last update: {lastrun}" - monitoringstate = params.get(state, 3) + monitoringstate = STATE_MAP.get(state, 3) yield monitoringstate, infotext @@ -44,14 +54,4 @@ def parse_stormshield_updates(string_table: StringTable) -> StringTable: service_name="Autoupdate %s", discovery_function=inventory_stormshield_updates, check_function=check_stormshield_updates, - check_ruleset_name="stormshield_updates", - check_default_parameters={ - "Not Available": 1, - "Broken": 2, - "Uptodate": 0, - "Disabled": 1, - "Never started": 0, - "Running": 0, - "Failed": 2, - }, ) 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 abc357df7b7..343dc6f1129 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 @@ -267,24 +267,26 @@ class ErrorReporter: ), # deprecated since 2.2 } - KNOWN_WATO_MISSING = { + ENFORCING_ONLY_RULESETS = { + # These plugins only have rules to be enforced (and configured), + # but no rules to configure discovered services. + # This may or may not be intentional and/or reasonable. + # If the plugins are discovered by default, it is likely to be unintentional. # type # instance # wato - ("check", "3ware_units", "raid"), # used to enforce the plugin - ("check", "brocade_tm", "brocade_tm"), - ("check", "lsi_array", "raid"), # used to enforce the plugin - ("check", "md", "raid"), # used to enforce the plugin - ("check", "mongodb_replication_info", "mongodb_replication_info"), - ("check", "moxa_iologik_register", "iologik_register"), + ("check", "3ware_units", "raid"), + ("check", "lsi_array", "raid"), + ("check", "md", "raid"), ("check", "netstat", "tcp_connections"), ("check", "nvidia_errors", "hw_errors"), - ("check", "qlogic_fcport", "qlogic_fcport"), - ("check", "stormshield_policy", "stormshield"), - ("check", "stormshield_updates", "stormshield_updates"), ("check", "vbox_guest", "vm_state"), ("check", "win_netstat", "tcp_connections"), ("check", "wmic_process", "wmic_process"), ("check", "zertificon_mail_queues", "zertificon_mail_queues"), ("check", "zpool_status", "zpool_status"), + } + + KNOWN_WATO_MISSING = { + # type # instance # wato ("discovery", "fileinfo", "fileinfo_groups"), ("discovery", "fileinfo_groups", "fileinfo_groups"), ("discovery", "sap_hana_fileinfo", "fileinfo_groups"), @@ -299,7 +301,7 @@ def __init__(self) -> None: self._last_exception: t.Optional[DefaultLoadingFailed] = None self._failed = False self._known_wato_unused = self.KNOWN_WATO_UNUSED.copy() - self._known_wato_missing = self.KNOWN_WATO_MISSING.copy() + self._known_wato_missing = self.KNOWN_WATO_MISSING | self.ENFORCING_ONLY_RULESETS def failed(self) -> bool: return self._failed