Skip to content

Commit

Permalink
plugins & rulesets: remove references to non-existing rulesets
Browse files Browse the repository at this point in the history
Change-Id: I08c912e5f1016b12482ba04ee9ef0ef9a1b2936f
  • Loading branch information
mo-ki committed Jan 13, 2025
1 parent 983a927 commit 87c0884
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 42 deletions.
25 changes: 13 additions & 12 deletions cmk/base/legacy_checks/brocade_tm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}


Expand All @@ -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 = {}
Expand All @@ -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
Expand Down Expand Up @@ -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),
},
)
3 changes: 1 addition & 2 deletions cmk/base/legacy_checks/mongodb_replication_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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",
)
3 changes: 1 addition & 2 deletions cmk/base/legacy_checks/moxa_iologik_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion cmk/base/legacy_checks/qlogic_fcport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
3 changes: 1 addition & 2 deletions cmk/base/legacy_checks/stormshield_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
)
24 changes: 12 additions & 12 deletions cmk/base/legacy_checks/stormshield_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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


Expand All @@ -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,
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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
Expand Down

0 comments on commit 87c0884

Please sign in to comment.