Skip to content

Commit

Permalink
clarify some enforcing properties
Browse files Browse the repository at this point in the history
Change-Id: I5bd09e2bd36acdf7322151e78a32e71379884aac
  • Loading branch information
mo-ki committed Jan 14, 2025
1 parent a8f726e commit 10fdfef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 12 additions & 3 deletions cmk/base/legacy_checks/netstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

from cmk.base.check_legacy_includes.netstat import check_netstat_generic

from cmk.agent_based.legacy.v0_unstable import LegacyCheckDefinition
from cmk.agent_based.legacy.v0_unstable import LegacyCheckDefinition, LegacyDiscoveryResult
from cmk.agent_based.v2 import StringTable

check_info = {}

Expand Down Expand Up @@ -41,8 +42,11 @@
# tcp4 0 0 127.0.0.1.1234 127.0.0.1.5678 ESTABLISHED


def parse_netstat(string_table):
def split_ip_address(ip_address):
Section = list[tuple[str, list[str], list[str], str]]


def parse_netstat(string_table: StringTable) -> Section:
def split_ip_address(ip_address: str) -> list[str]:
if ":" in ip_address:
return ip_address.rsplit(":", 1)
return ip_address.rsplit(".", 1)
Expand All @@ -68,10 +72,15 @@ def split_ip_address(ip_address):
return connections


def discover_netstat_never(section: Section) -> LegacyDiscoveryResult:
yield from () # can only be enforced


check_info["netstat"] = LegacyCheckDefinition(
name="netstat",
parse_function=parse_netstat,
service_name="TCP Connection %s",
discovery_function=discover_netstat_never,
check_function=check_netstat_generic,
check_ruleset_name="tcp_connections",
)
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ class ErrorReporter:
# If the plugins are discovered by default, it is likely to be unintentional.
# type # instance # wato
("check", "3ware_units", "raid"), # has no params, but can be enforced.
("check", "lsi_array", "raid"),
("check", "md", "raid"),
("check", "netstat", "tcp_connections"),
("check", "lsi_array", "raid"), # has no params, but can be enforced.
("check", "md", "raid"), # has no params, but can be enforced.
("check", "netstat", "tcp_connections"), # can only be enforced, never discovered.
("check", "nvidia_errors", "hw_errors"),
("check", "vbox_guest", "vm_state"),
("check", "win_netstat", "tcp_connections"),
Expand Down

0 comments on commit 10fdfef

Please sign in to comment.