lists.checkmk.com
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
List overview
Download
Checkmk git commits
April 2019
----- 2024 -----
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
checkmk-commits@lists.checkmk.com
15 participants
599 discussions
Start a n
N
ew thread
Create objects for host/service ruleset matching
by Lars Michelsen
Module: check_mk Branch: master Commit: dd834385411da59b972409c0a1776209f23ae74a URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dd834385411da5…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 15 12:00:21 2019 +0200 Create objects for host/service ruleset matching The RulesetMatchObject() ensures that we have a well crafted data structure when calling the ruleset matching methods of RulesetMatcher(). CMK-1941 Change-Id: Ie3ee597227be618e1b2eafc96d060a54b0d9026e --- cmk/utils/rulesets/ruleset_matcher.py | 49 +++++++--- cmk_base/config.py | 26 +++++- .../cmk/utils/rulesets/test_ruleset_matcher.py | 100 +++++++++++++++------ tests/unit/cmk_base/test_config.py | 53 +++++++++++ 4 files changed, 189 insertions(+), 39 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=dd83438541…
5 years, 5 months
1
0
0
0
Cleanup all direct config.is_no_ip_host calls
by Lars Michelsen
Module: check_mk Branch: master Commit: e4e8149cbcd49f76b24d1c3148371cfaf3824b67 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e4e8149cbcd49f…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 15 22:54:07 2019 +0200 Cleanup all direct config.is_no_ip_host calls Change-Id: I48168b9ab43b362399183aaf106617ece9829c0e --- cmk_base/config.py | 10 ---------- cmk_base/core_config.py | 14 +++++++------- cmk_base/core_nagios.py | 2 +- cmk_base/ip_lookup.py | 4 +++- tests/unit/cmk_base/test_config.py | 1 - 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/cmk_base/config.py b/cmk_base/config.py index e46dd33..748c64f 100644 --- a/cmk_base/config.py +++ b/cmk_base/config.py @@ -829,16 +829,6 @@ def parents_of(hostname): # -# IPv4/IPv6 -# - - -# TODO: Replace call sites with HostConfig access and remove this -def is_no_ip_host(hostname): - return get_config_cache().get_host_config(hostname).is_no_ip_host - - -# # Management board # diff --git a/cmk_base/core_config.py b/cmk_base/core_config.py index f41f1c9..be57b96 100644 --- a/cmk_base/core_config.py +++ b/cmk_base/core_config.py @@ -95,16 +95,16 @@ def get_configuration_warnings(): # TODO: Cleanup the hostcheck_commands_to_define, custom_commands_to_define thing def host_check_command(config_cache, - hostname, + host_config, ip, is_clust, hostcheck_commands_to_define=None, custom_commands_to_define=None): # Check dedicated host check command - values = config_cache.host_extra_conf(hostname, config.host_check_commands) + values = config_cache.host_extra_conf(host_config.hostname, config.host_check_commands) if values: value = values[0] - elif config.is_no_ip_host(hostname): + elif host_config.is_no_ip_host: value = "ok" elif config.monitoring_core == "cmc": value = "smart" @@ -118,7 +118,7 @@ def host_check_command(config_cache, return "check-mk-host-smart" elif value in ["ping", "smart"]: # Cluster host - ping_args = check_icmp_arguments_of(config_cache, hostname) + ping_args = check_icmp_arguments_of(config_cache, host_config.hostname) if is_clust and ip: # Do check cluster IP address if one is there return "check-mk-host-ping!%s" % ping_args @@ -141,8 +141,8 @@ def host_check_command(config_cache, command = "check-mk-host-custom-%d" % (len(hostcheck_commands_to_define) + 1) hostcheck_commands_to_define.append( (command, 'echo "$SERVICEOUTPUT:%s:%s$" && exit $SERVICESTATEID:%s:%s$' % - (hostname, service.replace('$HOSTNAME$', hostname), hostname, - service.replace('$HOSTNAME$', hostname)))) + (host_config.hostname, service.replace('$HOSTNAME$', host_config.hostname), + host_config.hostname, service.replace('$HOSTNAME$', host_config.hostname)))) return command elif value[0] == "tcp": @@ -156,7 +156,7 @@ def host_check_command(config_cache, return "check-mk-custom!" + autodetect_plugin(value[1]) raise MKGeneralException( - "Invalid value %r for host_check_command of host %s." % (value, hostname)) + "Invalid value %r for host_check_command of host %s." % (value, host_config.hostname)) def autodetect_plugin(command_line): diff --git a/cmk_base/core_nagios.py b/cmk_base/core_nagios.py index 1ca279e..38be483 100644 --- a/cmk_base/core_nagios.py +++ b/cmk_base/core_nagios.py @@ -202,7 +202,7 @@ def _create_nagios_hostdefs(cfg, config_cache, hostname, attrs): host_spec[key] = value # Host check command might differ from default - command = core_config.host_check_command(config_cache, hostname, ip, is_clust, + command = core_config.host_check_command(config_cache, host_config, ip, is_clust, cfg.hostcheck_commands_to_define, cfg.custom_commands_to_define) if command: diff --git a/cmk_base/ip_lookup.py b/cmk_base/ip_lookup.py index 16fa58a..f90aede 100644 --- a/cmk_base/ip_lookup.py +++ b/cmk_base/ip_lookup.py @@ -123,7 +123,9 @@ def cached_dns_lookup(hostname, family): cache[cache_id] = cached_ip return cached_ip - if config.is_no_ip_host(hostname): + host_config = config.get_config_cache().get_host_config(hostname) + + if host_config.is_no_ip_host: cache[cache_id] = None return None diff --git a/tests/unit/cmk_base/test_config.py b/tests/unit/cmk_base/test_config.py index 9aac531..8bcc5af 100644 --- a/tests/unit/cmk_base/test_config.py +++ b/tests/unit/cmk_base/test_config.py @@ -83,7 +83,6 @@ def test_is_piggyback_host_auto(monkeypatch, hostname, tags, with_data, result): ]) def test_is_no_ip_host(monkeypatch, hostname, tags, result): config_cache = _setup_host(monkeypatch, hostname, tags) - assert config.is_no_ip_host(hostname) == result assert config_cache.get_host_config(hostname).is_no_ip_host == result
5 years, 5 months
1
0
0
0
Cleanup all direct config.host_extra_conf calls
by Lars Michelsen
Module: check_mk Branch: master Commit: aed625b374c043485e1fabb5ecba7a0b2bbf3416 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=aed625b374c043…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 15 20:00:08 2019 +0200 Cleanup all direct config.host_extra_conf calls Change-Id: I4cb681bbb006b72b841f9b21a398e335438d6a98 --- cmk_base/automations/check_mk.py | 9 ++-- cmk_base/check_api.py | 13 ++++-- cmk_base/config.py | 62 ++++++++++----------------- cmk_base/core_config.py | 17 ++++---- cmk_base/core_nagios.py | 7 +-- cmk_base/data_sources/__init__.py | 8 ++-- cmk_base/data_sources/tcp.py | 2 +- cmk_base/discovery.py | 2 +- cmk_base/inventory.py | 3 +- tests/unit/cmk_base/test_data_sources_unit.py | 8 ++-- 10 files changed, 64 insertions(+), 67 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=aed625b374…
5 years, 5 months
1
0
0
0
Cleanup: moved all in_boolean_serviceconf_list calls to config_cache
by Lars Michelsen
Module: check_mk Branch: master Commit: 28a7e0a756fafcd461874174e52b8fc2ba3b4218 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=28a7e0a756fafc…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 15 16:58:10 2019 +0200 Cleanup: moved all in_boolean_serviceconf_list calls to config_cache Change-Id: Ieaec306e41cd8e01fa8aa9cc04e2a6a6f4dffd4c --- cmk_base/config.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cmk_base/config.py b/cmk_base/config.py index 0ac0ee0..e37b453 100644 --- a/cmk_base/config.py +++ b/cmk_base/config.py @@ -1343,7 +1343,7 @@ def service_ignored(hostname, check_plugin_name, description): return True if description is not None \ - and in_boolean_serviceconf_list(hostname, description, ignored_services): + and get_config_cache().in_boolean_serviceconf_list(hostname, description, ignored_services): return True return False @@ -1561,11 +1561,6 @@ def service_extra_conf(hostname, service, ruleset): return get_config_cache().service_extra_conf(hostname, service, ruleset) -# Compute outcome of a service rule set that just say yes/no -def in_boolean_serviceconf_list(hostname, descr, ruleset): - return get_config_cache().in_boolean_serviceconf_list(hostname, descr, ruleset) - - #. # .--Host rulesets-------------------------------------------------------. # | _ _ _ _ _ |
5 years, 5 months
1
0
0
0
Cleanup all direct config.service_extra_conf calls
by Lars Michelsen
Module: check_mk Branch: master Commit: d9636cc109603b73d3861dcf8fd05e1773464d16 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d9636cc109603b…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 15 19:39:54 2019 +0200 Cleanup all direct config.service_extra_conf calls Change-Id: I74b08c1ca5aa141c626f0933478db6122da8a995 --- cmk_base/check_api.py | 10 ++++-- cmk_base/config.py | 31 +++++-------------- cmk_base/core_config.py | 22 +++++++------ cmk_base/core_nagios.py | 55 +++++++++++++++++---------------- cmk_base/dump_host.py | 2 +- tests/unit/cmk_base/test_core_config.py | 7 +++-- 6 files changed, 61 insertions(+), 66 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=d9636cc109…
5 years, 5 months
1
0
0
0
Cleanup all direct config.host_extra_conf_merged calls
by Lars Michelsen
Module: check_mk Branch: master Commit: da9052c67d89f378b252d74b0c82ae610a72323f URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=da9052c67d89f3…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 15 19:44:07 2019 +0200 Cleanup all direct config.host_extra_conf_merged calls Change-Id: I243a3adf9b2e246ad4df9bb3eeeb08e794995de5 --- cmk_base/check_api.py | 7 ++++++- cmk_base/config.py | 4 ---- cmk_base/inventory.py | 3 ++- cmk_base/notify.py | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cmk_base/check_api.py b/cmk_base/check_api.py index 8bc1798..25383ce 100644 --- a/cmk_base/check_api.py +++ b/cmk_base/check_api.py @@ -208,7 +208,12 @@ def service_extra_conf(hostname, service, ruleset): host_extra_conf = _config.host_extra_conf in_binary_hostlist = _config.in_binary_hostlist -host_extra_conf_merged = _config.host_extra_conf_merged + + +# Compatibility wrapper for the pre 1.6 existant conf.host_extra_conf_merged() +def host_extra_conf_merged(hostname, conf): + return _config.get_config_cache().host_extra_conf_merged(hostname, conf) + # TODO: Only used by logwatch check. Can we clean this up? get_rule_options = _config.get_rule_options diff --git a/cmk_base/config.py b/cmk_base/config.py index 7e731e6..7dde648 100644 --- a/cmk_base/config.py +++ b/cmk_base/config.py @@ -1561,10 +1561,6 @@ def host_extra_conf(hostname, ruleset): return get_config_cache().host_extra_conf(hostname, ruleset) -def host_extra_conf_merged(hostname, conf): - return get_config_cache().host_extra_conf_merged(hostname, conf) - - #. # .--Host matching-------------------------------------------------------. # | _ _ _ _ _ _ | diff --git a/cmk_base/inventory.py b/cmk_base/inventory.py index c1ca54b..b77e0d4 100644 --- a/cmk_base/inventory.py +++ b/cmk_base/inventory.py @@ -328,7 +328,8 @@ def _gather_snmp_check_plugin_names_inventory(host_config, def _get_inv_params(hostname, section_name): - return config.host_extra_conf_merged(hostname, config.inv_parameters.get(section_name, [])) + return config.get_config_cache().host_extra_conf_merged( + hostname, config.inv_parameters.get(section_name, [])) #. diff --git a/cmk_base/notify.py b/cmk_base/notify.py index 91309f0..b60a033 100755 --- a/cmk_base/notify.py +++ b/cmk_base/notify.py @@ -589,8 +589,8 @@ def rbn_fallback_contacts(): def rbn_finalize_plugin_parameters(hostname, plugin, rule_parameters): # Right now we are only able to finalize notification plugins with dict parameters.. if isinstance(rule_parameters, dict): - parameters = config.host_extra_conf_merged(hostname, - config.notification_parameters.get(plugin, [])) + parameters = config.get_config_cache().host_extra_conf_merged( + hostname, config.notification_parameters.get(plugin, [])) parameters.update(rule_parameters) return parameters
5 years, 5 months
1
0
0
0
Removed unused code
by Lars Michelsen
Module: check_mk Branch: master Commit: b18a0519d744ec31faa5afdfcf7888d43fe95872 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b18a0519d744ec…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 15 20:05:37 2019 +0200 Removed unused code Change-Id: I8504c9fc525c2f21a308ff7eceb63bc16ba00548 --- cmk_base/config.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cmk_base/config.py b/cmk_base/config.py index 504d280..2346751 100644 --- a/cmk_base/config.py +++ b/cmk_base/config.py @@ -1041,10 +1041,6 @@ def hostgroups_of(hostname): return get_config_cache().host_extra_conf(hostname, host_groups) -def summary_hostgroups_of(hostname): - return get_config_cache().host_extra_conf(hostname, summary_host_groups) - - def contactgroups_of(hostname): cgrs = []
5 years, 5 months
1
0
0
0
Cleanup all direct config.in_binary_hostlist calls
by Lars Michelsen
Module: check_mk Branch: master Commit: 928ca9d5b8ee6b086f6b7d6dc6773306e24da2a4 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=928ca9d5b8ee6b…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 15 20:18:48 2019 +0200 Cleanup all direct config.in_binary_hostlist calls Change-Id: I5a8331717f13de010c9324afb3073199bdfe539f --- cmk_base/check_api.py | 4 +++- cmk_base/config.py | 30 +++++++++++++++++++----------- cmk_base/ip_lookup.py | 6 ++++-- cmk_base/parent_scan.py | 4 +++- cmk_base/snmp_scan.py | 3 ++- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/cmk_base/check_api.py b/cmk_base/check_api.py index ff08847..274bdd1 100644 --- a/cmk_base/check_api.py +++ b/cmk_base/check_api.py @@ -211,7 +211,9 @@ def host_extra_conf(hostname, ruleset): return _config.get_config_cache().host_extra_conf(hostname, ruleset) -in_binary_hostlist = _config.in_binary_hostlist +# Compatibility wrapper for the pre 1.6 existant conf.service_extra_conf() +def in_binary_hostlist(hostname, ruleset): + return _config.get_config_cache().in_binary_hostlist(hostname, ruleset) # Compatibility wrapper for the pre 1.6 existant conf.host_extra_conf_merged() diff --git a/cmk_base/config.py b/cmk_base/config.py index 2346751..b37f010 100644 --- a/cmk_base/config.py +++ b/cmk_base/config.py @@ -699,6 +699,8 @@ def all_active_hosts_with_duplicates(): # Returns a set of active hosts for this site def filter_active_hosts(hostlist, keep_offline_hosts=False, keep_duplicates=False): + config_cache = get_config_cache() + if only_hosts is None and distributed_wato_site is None: active_hosts = hostlist @@ -713,13 +715,14 @@ def filter_active_hosts(hostlist, keep_offline_hosts=False, keep_duplicates=Fals active_hosts = hostlist else: active_hosts = [ - hostname for hostname in hostlist if in_binary_hostlist(hostname, only_hosts) + hostname for hostname in hostlist + if config_cache.in_binary_hostlist(hostname, only_hosts) ] else: active_hosts = [ hostname for hostname in hostlist - if (keep_offline_hosts or in_binary_hostlist(hostname, only_hosts)) and + if (keep_offline_hosts or config_cache.in_binary_hostlist(hostname, only_hosts)) and host_is_member_of_site(hostname, distributed_wato_site) ] @@ -748,16 +751,25 @@ def duplicate_hosts(): # # This is not optimized for performance, so use in specific situations. def all_offline_hosts(): + config_cache = get_config_cache() + hostlist = filter_active_hosts( all_configured_realhosts().union(all_configured_clusters()), keep_offline_hosts=True) - return [hostname for hostname in hostlist if not in_binary_hostlist(hostname, only_hosts)] + return [ + hostname for hostname in hostlist + if not config_cache.in_binary_hostlist(hostname, only_hosts) + ] def all_configured_offline_hosts(): + config_cache = get_config_cache() hostlist = all_configured_realhosts().union(all_configured_clusters()) - return set([hostname for hostname in hostlist if not in_binary_hostlist(hostname, only_hosts)]) + return set([ + hostname for hostname in hostlist + if not config_cache.in_binary_hostlist(hostname, only_hosts) + ]) #. @@ -1003,7 +1015,7 @@ def snmp_port_of(hostname): def is_bulkwalk_host(hostname): # type: (str) -> bool if bulkwalk_hosts: - return in_binary_hostlist(hostname, bulkwalk_hosts) + return get_config_cache().in_binary_hostlist(hostname, bulkwalk_hosts) return False @@ -1017,7 +1029,7 @@ def bulk_walk_size_of(hostname): def is_snmpv2or3_without_bulkwalk_host(hostname): - return in_binary_hostlist(hostname, snmpv2c_hosts) + return get_config_cache().in_binary_hostlist(hostname, snmpv2c_hosts) # TODO: Replace call sites with HostConfig access and remove this @@ -1029,7 +1041,7 @@ def is_inline_snmp_host(hostname): # TODO: Better use "inline_snmp" once we have moved the code to an own module has_inline_snmp = "netsnmp" in sys.modules return has_inline_snmp and use_inline_snmp \ - and not in_binary_hostlist(hostname, non_inline_snmp_hosts) + and not get_config_cache().in_binary_hostlist(hostname, non_inline_snmp_hosts) # @@ -1617,10 +1629,6 @@ def in_extraconf_hostlist(hostlist, hostname): return False -def in_binary_hostlist(hostname, conf): - return get_config_cache().in_binary_hostlist(hostname, conf) - - def parse_host_rule(rule): rule, rule_options = get_rule_options(rule) diff --git a/cmk_base/ip_lookup.py b/cmk_base/ip_lookup.py index 36621e4..1bd9f9c 100644 --- a/cmk_base/ip_lookup.py +++ b/cmk_base/ip_lookup.py @@ -75,7 +75,9 @@ def lookup_ip_address(hostname, family=None): if config.fake_dns: return config.fake_dns - host_config = config.get_config_cache().get_host_config(hostname) + config_cache = config.get_config_cache() + + host_config = config_cache.get_host_config(hostname) # Honor simulation mode und usewalk hosts. Never contact the network. if config.simulation_mode or _enforce_localhost or \ @@ -96,7 +98,7 @@ def lookup_ip_address(hostname, family=None): # Hosts listed in dyndns hosts always use dynamic DNS lookup. # The use their hostname as IP address at all places - if config.in_binary_hostlist(hostname, config.dyndns_hosts): + if config_cache.in_binary_hostlist(hostname, config.dyndns_hosts): return hostname return cached_dns_lookup(hostname, family) diff --git a/cmk_base/parent_scan.py b/cmk_base/parent_scan.py index cba42d6..3f787e3 100644 --- a/cmk_base/parent_scan.py +++ b/cmk_base/parent_scan.py @@ -45,10 +45,12 @@ import cmk_base.ip_lookup as ip_lookup def do_scan_parents(hosts): + config_cache = config.get_config_cache() + if not hosts: hosts = [ h for h in config.all_active_realhosts() - if config.in_binary_hostlist(h, config.scanparent_hosts) + if config_cache.in_binary_hostlist(h, config.scanparent_hosts) ] parent_hosts = [] diff --git a/cmk_base/snmp_scan.py b/cmk_base/snmp_scan.py index 45fe57f..67961cb 100644 --- a/cmk_base/snmp_scan.py +++ b/cmk_base/snmp_scan.py @@ -74,7 +74,8 @@ def _snmp_scan(host_config, snmp.initialize_single_oid_cache(host_config) console.vverbose(" SNMP scan:\n") - if not config.in_binary_hostlist(host_config.hostname, config.snmp_without_sys_descr): + if not config.get_config_cache().in_binary_hostlist(host_config.hostname, + config.snmp_without_sys_descr): for oid, name in [(".1.3.6.1.2.1.1.1.0", "system description"), (".1.3.6.1.2.1.1.2.0", "system object")]: value = snmp.get_single_oid(host_config, oid, do_snmp_scan=do_snmp_scan)
5 years, 5 months
1
0
0
0
Cleanup: Made helper functions private, spreading config_cache usage
by Lars Michelsen
Module: check_mk Branch: master Commit: 8f3bf8acba2e31ae77a9bcdaba74046f92da8b66 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8f3bf8acba2e31…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 15 20:53:08 2019 +0200 Cleanup: Made helper functions private, spreading config_cache usage Change-Id: I46f2ff0374102817ed8838efbd7913a64d44b4a7 --- cmk_base/config.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/cmk_base/config.py b/cmk_base/config.py index b37f010..aac75fd 100644 --- a/cmk_base/config.py +++ b/cmk_base/config.py @@ -631,9 +631,9 @@ def all_active_hosts(): # hosts of other sitest or disabled hosts are excluded def all_active_realhosts(): active_realhosts = cmk_base.config_cache.get_set("active_realhosts") - if not active_realhosts.is_populated(): - active_realhosts.update(filter_active_hosts(all_configured_realhosts())) + config_cache = get_config_cache() + active_realhosts.update(_filter_active_hosts(config_cache, all_configured_realhosts())) active_realhosts.set_populated() return active_realhosts @@ -645,7 +645,8 @@ def all_active_clusters(): active_clusters = cmk_base.config_cache.get_set("active_clusters") if not active_clusters.is_populated(): - active_clusters.update(filter_active_hosts(all_configured_clusters())) + config_cache = get_config_cache() + active_clusters.update(_filter_active_hosts(config_cache, all_configured_clusters())) active_clusters.set_populated() return active_clusters @@ -692,22 +693,21 @@ def all_active_hosts_with_duplicates(): else: shadow_host_entries = [] - return filter_active_hosts(strip_tags(all_hosts) \ + config_cache = get_config_cache() + return _filter_active_hosts(config_cache, strip_tags(all_hosts) \ + strip_tags(clusters.keys()) \ + strip_tags(shadow_host_entries), keep_duplicates=True) -# Returns a set of active hosts for this site -def filter_active_hosts(hostlist, keep_offline_hosts=False, keep_duplicates=False): - config_cache = get_config_cache() - +def _filter_active_hosts(config_cache, hostlist, keep_offline_hosts=False, keep_duplicates=False): + """Returns a set of active hosts for this site""" if only_hosts is None and distributed_wato_site is None: active_hosts = hostlist elif only_hosts is None: active_hosts = [ hostname for hostname in hostlist - if host_is_member_of_site(hostname, distributed_wato_site) + if _host_is_member_of_site(config_cache, hostname, distributed_wato_site) ] elif distributed_wato_site is None: @@ -723,7 +723,7 @@ def filter_active_hosts(hostlist, keep_offline_hosts=False, keep_duplicates=Fals active_hosts = [ hostname for hostname in hostlist if (keep_offline_hosts or config_cache.in_binary_hostlist(hostname, only_hosts)) and - host_is_member_of_site(hostname, distributed_wato_site) + _host_is_member_of_site(config_cache, hostname, distributed_wato_site) ] if keep_duplicates: @@ -753,8 +753,10 @@ def duplicate_hosts(): def all_offline_hosts(): config_cache = get_config_cache() - hostlist = filter_active_hosts( - all_configured_realhosts().union(all_configured_clusters()), keep_offline_hosts=True) + hostlist = _filter_active_hosts( + config_cache, + all_configured_realhosts().union(all_configured_clusters()), + keep_offline_hosts=True) return [ hostname for hostname in hostlist @@ -785,8 +787,8 @@ def all_configured_offline_hosts(): # '----------------------------------------------------------------------' -def host_is_member_of_site(hostname, site): - for tag in get_config_cache().get_host_config(hostname).tags: +def _host_is_member_of_site(config_cache, hostname, site): + for tag in config_cache.get_host_config(hostname).tags: if tag.startswith("site:"): return site == tag[5:] # hosts without a site: tag belong to all sites
5 years, 5 months
1
0
0
0
Cleanup all direct config.is_ipv6_primary calls
by Lars Michelsen
Module: check_mk Branch: master Commit: e1ff7db2038acacae7854c985db1e9233b2d57e8 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e1ff7db2038aca…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 15 22:23:45 2019 +0200 Cleanup all direct config.is_ipv6_primary calls Change-Id: Ic924c8d0492d7d2d352248d6b3c1c280809dea1e --- cmk_base/automations/check_mk.py | 12 +++---- cmk_base/check_api.py | 7 ++++- cmk_base/config.py | 5 --- cmk_base/core_config.py | 64 ++++++++++++++++++++------------------ cmk_base/core_nagios.py | 13 ++++---- cmk_base/data_sources/abstract.py | 4 ++- cmk_base/data_sources/programs.py | 7 +++-- cmk_base/data_sources/snmp.py | 4 ++- cmk_base/data_sources/tcp.py | 2 +- cmk_base/dump_host.py | 30 +++++++++--------- cmk_base/ip_lookup.py | 7 ++--- cmk_base/snmp.py | 5 ++- tests/unit/cmk_base/test_config.py | 1 - 13 files changed, 86 insertions(+), 75 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=e1ff7db203…
5 years, 5 months
1
0
0
0
← Newer
1
...
20
21
22
23
24
25
26
...
60
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Results per page:
10
25
50
100
200