Skip to content

Commit

Permalink
16143 Add --snmp-backend option to cmk
Browse files Browse the repository at this point in the history
CMK-6270

Change-Id: Ib8a9a631b3a40a19f1e50437bbe4e357267560c3
  • Loading branch information
Synss committed Oct 19, 2023
1 parent 62e1583 commit 0d2f16b
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 18 deletions.
13 changes: 13 additions & 0 deletions .werks/16143
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Title: Add --snmp-backend option to cmk
Class: feature
Compatible: compat
Component: checks
Date: 1697629280
Edition: cre
Level: 1
Version: 2.3.0b1

Add <tt>--snmp-backend = classic|inline|stored-walk</tt> option to
the cmk command-line utility. The following modes are affected:
dump-agent, snmpwalk, snmpget, check-discovery, discover, check,
inventory, inventory-as-check, inventorize-marked-hosts.
5 changes: 5 additions & 0 deletions cmk/base/automations/check_mk.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def execute(self, args: list[str]) -> ServiceDiscoveryResult:
on_error=on_error,
selected_sections=NO_SELECTION,
simulation_mode=config.simulation_mode,
snmp_backend_override=None,
)
for hostname in hostnames:

Expand Down Expand Up @@ -490,6 +491,7 @@ def _execute_discovery(
on_error=on_error,
selected_sections=NO_SELECTION,
simulation_mode=config.simulation_mode,
snmp_backend_override=None,
)
ip_address = (
None
Expand Down Expand Up @@ -599,6 +601,7 @@ def _execute_autodiscovery() -> tuple[Mapping[HostName, DiscoveryResult], bool]:
on_error=OnError.IGNORE,
selected_sections=NO_SELECTION,
simulation_mode=config.simulation_mode,
snmp_backend_override=None,
)
section_plugins = SectionPluginMapper()
host_label_plugins = HostLabelPluginMapper(ruleset_matcher=ruleset_matcher)
Expand Down Expand Up @@ -1926,6 +1929,7 @@ def _execute_agent(
discovery=1.5 * check_interval,
inventory=1.5 * check_interval,
),
snmp_backend_override=None,
):
source_info = source.source_info()
if source_info.fetcher_type is FetcherType.SNMP:
Expand Down Expand Up @@ -2300,6 +2304,7 @@ def execute(self, args: list[str]) -> GetAgentOutputResult:
discovery=1.5 * check_interval,
inventory=1.5 * check_interval,
),
snmp_backend_override=None,
):
source_info = source.source_info()
if source_info.fetcher_type is FetcherType.SNMP:
Expand Down
8 changes: 6 additions & 2 deletions cmk/base/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def __init__(
selected_sections: SectionNameCollection,
simulation_mode: bool,
max_cachefile_age: MaxAge | None = None,
snmp_backend_override: SNMPBackendEnum | None,
) -> None:
self.config_cache: Final = config_cache
self.file_cache_options: Final = file_cache_options
Expand All @@ -249,6 +250,7 @@ def __init__(
self.selected_sections: Final = selected_sections
self.simulation_mode: Final = simulation_mode
self.max_cachefile_age: Final = max_cachefile_age
self.snmp_backend_override: Final = snmp_backend_override

def __call__(
self, host_name: HostName, *, ip_address: HostAddress | None
Expand Down Expand Up @@ -284,8 +286,10 @@ def __call__(
on_scan_error=self.on_error if nodes is None else OnError.RAISE,
simulation_mode=self.simulation_mode,
file_cache_options=self.file_cache_options,
file_cache_max_age=self.max_cachefile_age
or self.config_cache.max_cachefile_age(host_name),
file_cache_max_age=(
self.max_cachefile_age or self.config_cache.max_cachefile_age(host_name)
),
snmp_backend_override=self.snmp_backend_override,
)
for host_name_, ip_address_ in hosts
),
Expand Down
1 change: 1 addition & 0 deletions cmk/base/dump_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def dump_host(config_cache: ConfigCache, hostname: HostName) -> None:
config_cache=config_cache,
simulation_mode=config.simulation_mode,
file_cache_max_age=MaxAge.zero(),
snmp_backend_override=None,
)
]

Expand Down
Loading

0 comments on commit 0d2f16b

Please sign in to comment.