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
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 -----
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
Fix refactoring issue uncovered by mypy
by Lars Michelsen
Module: check_mk Branch: master Commit: db0ccf965ce8cea865e6b4953f0cbb3333d59685 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=db0ccf965ce8ce…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Wed Apr 24 13:58:00 2019 +0200 Fix refactoring issue uncovered by mypy Change-Id: I6cd60de497310cbb8000d05015327bbfb78930d3 --- cmk_base/discovery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmk_base/discovery.py b/cmk_base/discovery.py index 5f2fc34..ebcf2e0 100644 --- a/cmk_base/discovery.py +++ b/cmk_base/discovery.py @@ -351,7 +351,7 @@ def check_discovery(hostname, ipaddress): sources, use_caches=data_sources.abstract.DataSource.get_may_use_cache_file()) services = _get_host_services( - host_name, ipaddress, sources, multi_host_sections, on_error="raise") + host_config, ipaddress, sources, multi_host_sections, on_error="raise") need_rediscovery = False
5 years, 2 months
1
0
0
0
Spread mypy usage
by Lars Michelsen
Module: check_mk Branch: master Commit: bda0d5520643ce5b015159c7c728411fed7c6dd2 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bda0d5520643ce…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Wed Apr 24 13:57:33 2019 +0200 Spread mypy usage Change-Id: Iac548e19cb5e3154e0e7fd9cba47902e20d3d534 --- cmk_base/discovery.py | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/cmk_base/discovery.py b/cmk_base/discovery.py index b8e3e31..5f2fc34 100644 --- a/cmk_base/discovery.py +++ b/cmk_base/discovery.py @@ -28,6 +28,7 @@ import os import socket import time import signal +from typing import Callable, List, Text, Optional, Dict, Tuple # pylint: disable=unused-import from cmk.utils.regex import regex import cmk.utils.tty as tty @@ -322,13 +323,17 @@ def discover_on_host(config_cache, @cmk_base.decorator.handle_check_mk_check_result("discovery", "Check_MK Discovery") def check_discovery(hostname, ipaddress): + # type: (str, Optional[str]) -> Tuple[int, List[Text], List[Text], List[Tuple]] config_cache = config.get_config_cache() host_config = config_cache.get_host_config(hostname) params = discovery_check_parameters(hostname) or \ default_discovery_check_parameters() - status, infotexts, long_infotexts, perfdata = 0, [], [], [] + status = 0 + infotexts = [] + long_infotexts = [] + perfdata = [] # type: List[Tuple] # In case of keepalive discovery we always have an ipaddress. When called as non keepalive # ipaddress is always None @@ -346,12 +351,13 @@ def check_discovery(hostname, ipaddress): sources, use_caches=data_sources.abstract.DataSource.get_may_use_cache_file()) services = _get_host_services( - hostname, ipaddress, sources, multi_host_sections, on_error="raise") + host_name, ipaddress, sources, multi_host_sections, on_error="raise") need_rediscovery = False params_rediscovery = params.get("inventory_rediscovery", {}) + item_filters = None # type: Optional[Callable] if params_rediscovery.get("service_whitelist", []) or\ params_rediscovery.get("service_blacklist", []): # whitelist. if none is specified, this matches everything @@ -363,15 +369,13 @@ def check_discovery(hostname, ipaddress): item_filters = lambda hostname, check_plugin_name, item:\ _discovery_filter_by_lists(hostname, check_plugin_name, item, whitelist, blacklist) - else: - item_filters = None for check_state, title, params_key, default_state in [ ("new", "unmonitored", "severity_unmonitored", config.inventory_check_severity), ("vanished", "vanished", "severity_vanished", 0), ]: - affected_check_plugin_names = {} + affected_check_plugin_names = {} # type: Dict[str, int] count = 0 unfiltered = False @@ -386,15 +390,15 @@ def check_discovery(hostname, ipaddress): unfiltered = True long_infotexts.append( - "%s: %s: %s" % (title, check_plugin_name, - config.service_description(hostname, check_plugin_name, item))) + u"%s: %s: %s" % (title, check_plugin_name, + config.service_description(hostname, check_plugin_name, item))) if affected_check_plugin_names: info = ", ".join(["%s:%d" % e for e in affected_check_plugin_names.items()]) st = params.get(params_key, default_state) status = cmk_base.utils.worst_service_state(status, st) infotexts.append( - "%d %s services (%s)%s" % (count, title, info, check_api_utils.state_markers[st])) + u"%d %s services (%s)%s" % (count, title, info, check_api_utils.state_markers[st])) if params.get("inventory_rediscovery", False): mode = params["inventory_rediscovery"]["mode"] @@ -403,13 +407,13 @@ def check_discovery(hostname, ipaddress): (check_state == "vanished" and mode in ( 1, 2, 3 ))): need_rediscovery = True else: - infotexts.append("no %s services found" % title) + infotexts.append(u"no %s services found" % title) for (check_plugin_name, item), (check_source, _unused_paramstring) in services.items(): if check_source == "ignored": long_infotexts.append( - "ignored: %s: %s" % (check_plugin_name, - config.service_description(hostname, check_plugin_name, item))) + u"ignored: %s: %s" % + (check_plugin_name, config.service_description(hostname, check_plugin_name, item))) if need_rediscovery: if host_config.is_cluster: @@ -417,7 +421,7 @@ def check_discovery(hostname, ipaddress): _set_rediscovery_flag(nodename) else: _set_rediscovery_flag(hostname) - infotexts.append("rediscovery scheduled") + infotexts.append(u"rediscovery scheduled") # Add data source information to check results for source in sources.get_data_sources(): @@ -425,7 +429,7 @@ def check_discovery(hostname, ipaddress): # Do not output informational (state = 0) things. These information are shown by the "Check_MK" service if source_state != 0: status = max(status, source_state) - infotexts.append("[%s] %s" % (source.id(), source_output)) + infotexts.append(u"[%s] %s" % (source.id(), source_output)) return status, infotexts, long_infotexts, perfdata @@ -923,6 +927,9 @@ def _validate_discovered_items(hostname, check_plugin_name, discovered_items): return results +DiscoveredServicesTable = Dict[Tuple[str, str], Tuple[str, str]] + + # Creates a table of all services that a host has or could have according # to service discovery. The result is a dictionary of the form # (check_plugin_name, item) -> (check_source, paramstring) @@ -939,6 +946,7 @@ def _validate_discovered_items(hostname, check_plugin_name, discovered_items): # "clustered_old" : Old service found on a node that belongs to a cluster # This function is cluster-aware def _get_host_services(host_config, ipaddress, sources, multi_host_sections, on_error): + # type: (config.HostConfig, Optional[str], data_sources.DataSources, data_sources.MultiHostSections, str) -> DiscoveredServicesTable if host_config.is_cluster: return _get_cluster_services(host_config.hostname, ipaddress, sources, multi_host_sections, on_error) @@ -949,6 +957,7 @@ def _get_host_services(host_config, ipaddress, sources, multi_host_sections, on_ # Do the actual work for a non-cluster host or node def _get_node_services(hostname, ipaddress, sources, multi_host_sections, on_error): + # type: (str, Optional[str], data_sources.DataSources, data_sources.MultiHostSections, str) -> DiscoveredServicesTable services = _get_discovered_services(hostname, ipaddress, sources, multi_host_sections, on_error) config_cache = config.get_config_cache() @@ -976,8 +985,9 @@ def _get_node_services(hostname, ipaddress, sources, multi_host_sections, on_err # Part of _get_node_services that deals with discovered services def _get_discovered_services(hostname, ipaddress, sources, multi_host_sections, on_error): + # type: (str, Optional[str], data_sources.DataSources, data_sources.MultiHostSections, str) -> DiscoveredServicesTable # Create a dict from check_plugin_name/item to check_source/paramstring - services = {} + services = {} # type: DiscoveredServicesTable # In 'multi_host_sections = _get_host_sections_for_discovery(..)' # we've already discovered the right check plugin names. @@ -1056,6 +1066,7 @@ def _merge_manual_services(services, hostname, on_error): # Do the work for a cluster def _get_cluster_services(hostname, ipaddress, sources, multi_host_sections, on_error): + # type: (str, Optional[str], data_sources.DataSources, data_sources.MultiHostSections, str) -> DiscoveredServicesTable nodes = config.nodes_of(hostname) config_cache = config.get_config_cache() @@ -1068,7 +1079,7 @@ def _get_cluster_services(hostname, ipaddress, sources, multi_host_sections, on_ # Get services of the nodes. We are only interested in "old", "new" and "vanished" # From the states and parameters of these we construct the final state per service. - cluster_items = {} + cluster_items = {} # type: DiscoveredServicesTable for node in nodes: node_ipaddress = ip_lookup.lookup_ip_address(node) node_sources = _get_sources_for_discovery(
5 years, 2 months
1
0
0
0
Cleanup config.parents_of
by Lars Michelsen
Module: check_mk Branch: master Commit: d8ff2e5ddf2db80494eb38dd6acb1f47fccab7c0 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d8ff2e5ddf2db8…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 22 17:12:24 2019 +0200 Cleanup config.parents_of CMK-2030 Change-Id: I05be7e80214df5565ccc6f71833bb903459ca6eb --- cmk_base/config.py | 26 +++++++++++--------------- cmk_base/core_nagios.py | 2 +- cmk_base/dump_host.py | 2 +- cmk_base/parent_scan.py | 5 ++++- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/cmk_base/config.py b/cmk_base/config.py index cc65ed1..9920e9d 100644 --- a/cmk_base/config.py +++ b/cmk_base/config.py @@ -736,21 +736,6 @@ def get_additional_ipaddresses_of(hostname): host_attributes.get(hostname, {}).get("additional_ipv6addresses", [])) -def parents_of(hostname): - # type: (str) -> List[str] - config_cache = get_config_cache() - par = config_cache.host_extra_conf(hostname, parents) - # Use only those parents which are defined and active in - # all_hosts. - used_parents = [] - for p in par: - ps = p.split(",") - for pss in ps: - if pss in config_cache.all_active_realhosts(): - used_parents.append(pss) - return used_parents - - # # Management board # @@ -2490,6 +2475,7 @@ class HostConfig(object): self.alias = self._get_alias() self.is_cluster = self._is_cluster() self.part_of_clusters = self._config_cache.clusters_of(hostname) + self.parents = self._get_parents() # TODO: Rename self.tags to self.tag_list and self.tag_groups to self.tags self.tags = self._config_cache.tag_list_of_host(self.hostname) @@ -2570,6 +2556,16 @@ class HostConfig(object): return aliases[0] + def _get_parents(self): + # type: () -> List[str] + """Use only those parents which are defined and active in all_hosts""" + used_parents = [] + for parent_names in self._config_cache.host_extra_conf(self.hostname, parents): + for parent_name in parent_names.split(","): + if parent_name in self._config_cache.all_active_realhosts(): + used_parents.append(parent_name) + return used_parents + def _get_host_labels(self): """Returns the effective set of host labels from all available sources diff --git a/cmk_base/core_nagios.py b/cmk_base/core_nagios.py index d879052..b390a58 100644 --- a/cmk_base/core_nagios.py +++ b/cmk_base/core_nagios.py @@ -236,7 +236,7 @@ def _create_nagios_host_spec(cfg, config_cache, hostname, attrs): config.extra_host_conf.get("parents", [])) if not extra_conf_parents: - parents_list = config.parents_of(hostname) + parents_list = host_config.parents if parents_list: host_spec["parents"] = ",".join(parents_list) diff --git a/cmk_base/dump_host.py b/cmk_base/dump_host.py index 202da44..7219d50 100644 --- a/cmk_base/dump_host.py +++ b/cmk_base/dump_host.py @@ -84,7 +84,7 @@ def dump_host(hostname): if host_config.is_cluster: parents_list = config.nodes_of(hostname) else: - parents_list = config.parents_of(hostname) + parents_list = host_config.parents if len(parents_list) > 0: console.output(tty.yellow + "Parents: " + tty.normal + ", ".join(parents_list) + "\n") diff --git a/cmk_base/parent_scan.py b/cmk_base/parent_scan.py index 0da264d..3f888b1 100644 --- a/cmk_base/parent_scan.py +++ b/cmk_base/parent_scan.py @@ -82,8 +82,11 @@ def do_scan_parents(hosts): while len(chunk) < config.max_num_processes and len(hosts) > 0: host = hosts[0] del hosts[0] + + host_config = config_cache.get_host_config(host) + # skip hosts that already have a parent - if config.parents_of(host): + if host_config.parents: console.verbose("(manual parent) ") continue chunk.append(host)
5 years, 2 months
1
0
0
0
Cleanup fragments of ancient host alias configuration
by Lars Michelsen
Module: check_mk Branch: master Commit: 4017f149b37acdc61b5ce1e5e8f63e644c3fecd8 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4017f149b37acd…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Sun Apr 21 19:45:01 2019 +0200 Cleanup fragments of ancient host alias configuration CMK-2030 Change-Id: I54fb25c1f210e93961a38d2eefb1aef1a264f4c0 --- cmk_base/core_nagios.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/cmk_base/core_nagios.py b/cmk_base/core_nagios.py index 6ef770b..336ccc4 100644 --- a/cmk_base/core_nagios.py +++ b/cmk_base/core_nagios.py @@ -191,11 +191,11 @@ def _create_nagios_host_spec(cfg, config_cache, hostname, attrs): # | | # |_| 1. normal, physical hosts - alias = hostname host_spec = { "host_name": hostname, "use": config.cluster_template if is_clust else config.host_template, "address": ip if ip else core_config.fallback_ip_for(host_config), + "alias": attrs["alias"], } # Add custom macros @@ -243,14 +243,8 @@ def _create_nagios_host_spec(cfg, config_cache, hostname, attrs): elif is_clust: # Special handling of clusters - alias = "cluster of %s" % ", ".join(nodes) host_spec["parents"] = ",".join(nodes) - # Output alias, but only if it's not defined in extra_host_conf - alias = config.alias_of(hostname, None) - if alias is not None: - host_spec["alias"] = alias - # Custom configuration last -> user may override all other values host_spec.update( _extra_host_conf_of(config_cache, hostname, exclude=["parents"] if is_clust else []))
5 years, 2 months
1
0
0
0
Add unit tests for host alias setting
by Lars Michelsen
Module: check_mk Branch: master Commit: 16c8434e09e476e79aafe6e6ce0916491643dcf7 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=16c8434e09e476…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Sun Apr 21 19:40:22 2019 +0200 Add unit tests for host alias setting CMK-2030 Change-Id: I2d557290b86aa9aa717b265adc74bad1064ef41e --- cmk_base/core_nagios.py | 7 ++- tests/testlib/base.py | 5 +- tests/unit/cmk_base/test_core_nagios.py | 107 +++++++++++++++++++++++++++++++- 3 files changed, 114 insertions(+), 5 deletions(-) diff --git a/cmk_base/core_nagios.py b/cmk_base/core_nagios.py index 75f4cd2..6ef770b 100644 --- a/cmk_base/core_nagios.py +++ b/cmk_base/core_nagios.py @@ -170,11 +170,12 @@ def _create_nagios_config_host(cfg, config_cache, hostname): cfg.outfile.write("# ----------------------------------------------------\n") host_attrs = core_config.get_host_attributes(hostname, config_cache) if config.generate_hostconf: - _create_nagios_hostdefs(cfg, config_cache, hostname, host_attrs) + host_spec = _create_nagios_host_spec(cfg, config_cache, hostname, host_attrs) + cfg.outfile.write(_format_nagios_object("host", host_spec).encode("utf-8")) _create_nagios_servicedefs(cfg, config_cache, hostname, host_attrs) -def _create_nagios_hostdefs(cfg, config_cache, hostname, attrs): +def _create_nagios_host_spec(cfg, config_cache, hostname, attrs): host_config = config_cache.get_host_config(hostname) is_clust = config.is_cluster(hostname) @@ -253,7 +254,7 @@ def _create_nagios_hostdefs(cfg, config_cache, hostname, attrs): # Custom configuration last -> user may override all other values host_spec.update( _extra_host_conf_of(config_cache, hostname, exclude=["parents"] if is_clust else [])) - cfg.outfile.write(_format_nagios_object("host", host_spec).encode("utf-8")) + return host_spec def _create_nagios_servicedefs(cfg, config_cache, hostname, host_attrs): diff --git a/tests/testlib/base.py b/tests/testlib/base.py index 712c39f..d31bc4b 100644 --- a/tests/testlib/base.py +++ b/tests/testlib/base.py @@ -24,7 +24,9 @@ class Scenario(object): #self.config["host_tags"][hostname] = tags return self - def add_cluster(self, hostname, tags, folder="/", nodes=None): + def add_cluster(self, hostname, tags=None, folder="/", nodes=None): + if tags is None: + tags = [] if nodes is None: nodes = [] name_with_tags = "%s|%s" % (hostname, "|".join(tags)) @@ -45,5 +47,6 @@ class Scenario(object): for key, value in self.config.items(): monkeypatch.setattr(config, key, value) + self.config_cache = config.get_config_cache() self.config_cache.initialize() return self.config_cache diff --git a/tests/unit/cmk_base/test_core_nagios.py b/tests/unit/cmk_base/test_core_nagios.py index 81c4869..60f863b 100644 --- a/tests/unit/cmk_base/test_core_nagios.py +++ b/tests/unit/cmk_base/test_core_nagios.py @@ -1,6 +1,12 @@ # encoding: utf-8 - +# pylint: disable=redefined-outer-name import itertools +from StringIO import StringIO + +import pytest # type: ignore +from testlib.base import Scenario + +import cmk_base.core_config as core_config import cmk_base.core_nagios as core_nagios @@ -21,3 +27,102 @@ def test_format_nagios_object(): } """ % tuple(itertools.chain(*sorted(spec.items(), key=lambda x: x[0]))) + + +def ts(): + ts1 = Scenario().add_host("localhost") + result1 = { + '_ADDRESS_4': '127.0.0.1', + '_ADDRESS_6': '', + '_ADDRESS_FAMILY': '4', + '_TAGS': '', + '_FILENAME': '/', + 'address': '127.0.0.1', + 'alias': 'localhost', + 'check_command': 'check-mk-host-ping!-w 200.00,80.00% -c 500.00,100.00%', + 'host_name': 'localhost', + 'hostgroups': 'check_mk', + 'use': 'check_mk_host', + } + + yield ts1, result1 + + ts2 = Scenario().add_host("localhost") + ts2.set_option("extra_host_conf", { + "alias": [(u'lOCALhost', ['localhost']),], + }) + result2 = { + '_ADDRESS_4': '127.0.0.1', + '_ADDRESS_6': '', + '_ADDRESS_FAMILY': '4', + '_FILENAME': '/', + '_TAGS': '', + 'address': '127.0.0.1', + 'alias': u'lOCALhost', + 'check_command': 'check-mk-host-ping!-w 200.00,80.00% -c 500.00,100.00%', + 'host_name': 'localhost', + 'hostgroups': 'check_mk', + 'use': 'check_mk_host', + } + + yield ts2, result2 + + ts3 = Scenario().add_cluster("localhost") + result3 = { + '_ADDRESS_4': '127.0.0.1', + '_ADDRESS_6': '', + '_ADDRESS_FAMILY': '4', + '_FILENAME': '/', + '_NODEIPS': '', + '_NODEIPS_4': '', + '_NODEIPS_6': '', + '_NODENAMES': '', + '_TAGS': '', + 'address': '127.0.0.1', + 'alias': 'localhost', + 'check_command': 'check-mk-host-ping!-w 200.00,80.00% -c 500.00,100.00%', + 'host_name': 'localhost', + 'hostgroups': 'check_mk', + 'parents': '', + 'use': 'check_mk_cluster', + } + + yield ts3, result3 + + ts4 = Scenario().add_cluster("localhost") + ts4.set_option("extra_host_conf", { + "alias": [(u'lOCALhost', ['localhost']),], + }) + result4 = { + '_ADDRESS_4': '127.0.0.1', + '_ADDRESS_6': '', + '_ADDRESS_FAMILY': '4', + '_FILENAME': '/', + '_NODEIPS': '', + '_NODEIPS_4': '', + '_NODEIPS_6': '', + '_NODENAMES': '', + '_TAGS': '', + 'address': '127.0.0.1', + 'alias': u'lOCALhost', + 'check_command': 'check-mk-host-ping!-w 200.00,80.00% -c 500.00,100.00%', + 'host_name': 'localhost', + 'hostgroups': 'check_mk', + 'parents': '', + 'use': 'check_mk_cluster', + } + + yield ts4, result4 + + +(a)pytest.mark.parametrize("ts,result", ts()) +def test_create_nagios_host_spec(ts, result, monkeypatch): + outfile = StringIO() + cfg = core_nagios.NagiosConfig(outfile, ["localhost"]) + + config_cache = ts.apply(monkeypatch) + host_attrs = core_config.get_host_attributes("localhost", config_cache) + + host_spec = core_nagios._create_nagios_host_spec(cfg, config_cache, "localhost", host_attrs) + + assert host_spec == result
5 years, 2 months
1
0
0
0
Cleanup some config.is_cluster call sites
by Lars Michelsen
Module: check_mk Branch: master Commit: b6abe72773fde5e67d153f06d57c0d92c59c58a2 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b6abe72773fde5…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 22 08:19:16 2019 +0200 Cleanup some config.is_cluster call sites CMK-2030 Change-Id: I2379d87ce2db68c7db91ef98a5db9d68ebf311b8 --- cmk_base/checking.py | 18 ++++++++++-------- cmk_base/core_nagios.py | 15 ++++++++------- cmk_base/crash_reporting.py | 2 +- cmk_base/inventory.py | 31 +++++++++++++++++++++++-------- 4 files changed, 42 insertions(+), 24 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=b6abe72773…
5 years, 2 months
1
0
0
0
Cleanup remaining config.is_cluster call sites
by Lars Michelsen
Module: check_mk Branch: master Commit: ee6dd3fe6ff29da55531c44ae5b84bf570cc6287 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ee6dd3fe6ff29d…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Apr 22 09:55:50 2019 +0200 Cleanup remaining config.is_cluster call sites CMK-2030 Change-Id: Ieffc5e14a37f3c007de0c6c964d94ff1815cfce1 --- cmk_base/automations/check_mk.py | 34 ++++++++++++++-------- cmk_base/config.py | 30 +++++++++---------- cmk_base/discovery.py | 63 +++++++++++++++++++++++++--------------- 3 files changed, 76 insertions(+), 51 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=ee6dd3fe6f…
5 years, 2 months
1
0
0
0
Cleanup: Started cleaning up config.is_cluster call sites
by Lars Michelsen
Module: check_mk Branch: master Commit: 14bc00a9ad18d8d9bf8fef31c1eca96753e69a7e URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=14bc00a9ad18d8…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Sun Apr 21 19:48:45 2019 +0200 Cleanup: Started cleaning up config.is_cluster call sites CMK-2030 Change-Id: Ifc1b0b403b5097455a05b1136ad59043e0dadb19 --- cmk_base/check_api.py | 3 ++- cmk_base/checking.py | 3 ++- cmk_base/config.py | 25 +++++++++++++------------ cmk_base/core_config.py | 16 ++++++++-------- cmk_base/core_nagios.py | 28 ++++++++++++++-------------- cmk_base/data_sources/abstract.py | 4 ++-- cmk_base/data_sources/programs.py | 2 +- cmk_base/dump_host.py | 4 ++-- cmk_base/inventory.py | 5 ++++- cmk_base/modes/check_mk.py | 5 ++++- 10 files changed, 52 insertions(+), 43 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=14bc00a9ad…
5 years, 2 months
1
0
0
0
Fixed issue in recent change
by Lars Michelsen
Module: check_mk Branch: master Commit: 2470b2ce399ff8b7b55bab8c9cf057b116621986 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2470b2ce399ff8…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Wed Apr 24 13:01:48 2019 +0200 Fixed issue in recent change Change-Id: I0664020b1609124d945ea7ea3d4449a60b45d3fa --- cmk_base/automations/check_mk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmk_base/automations/check_mk.py b/cmk_base/automations/check_mk.py index 1901ec3..c53dd6a 100644 --- a/cmk_base/automations/check_mk.py +++ b/cmk_base/automations/check_mk.py @@ -1125,7 +1125,6 @@ class AutomationDiagHost(Automation): config_cache = config.get_config_cache() host_config = config_cache.get_host_config(hostname) - snmp_config = host_config.snmp_config() # In 1.5 the tcp connect timeout has been added. The automation may # be called from a remote site with an older version. For this reason @@ -1159,6 +1158,8 @@ class AutomationDiagHost(Automation): except: raise MKGeneralException("Cannot resolve hostname %s into IP address" % hostname) + snmp_config = host_config.snmp_config(ipaddress) + try: if test == 'ping': base_cmd = "ping6" if host_config.is_ipv6_primary else "ping"
5 years, 2 months
1
0
0
0
extend postgres tests
by Moritz Kiemer
Module: check_mk Branch: master Commit: 4f0c85c0c841aa4bbb258083c6dbd63fe7e9f3e3 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4f0c85c0c841aa…
Author: Moritz Kiemer <mo(a)mathias-kettner.de> Date: Wed Apr 24 12:11:34 2019 +0200 extend postgres tests Change-Id: I066d31033429dc7c521d9d958b19cc51838fae0e --- .../checks/generictests/datasets/postgres_stats.py | 41 +++++++++++++++------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/tests/unit/checks/generictests/datasets/postgres_stats.py b/tests/unit/checks/generictests/datasets/postgres_stats.py index 5ae2a18..686a11f 100644 --- a/tests/unit/checks/generictests/datasets/postgres_stats.py +++ b/tests/unit/checks/generictests/datasets/postgres_stats.py @@ -4,6 +4,11 @@ checkname = 'postgres_stats' +mock_item_state = { + '': 1547250000.0, +} + + freeze_time = '2019-01-12 00:00:00' @@ -26,15 +31,27 @@ discovery = {'': [(u'ANALYZE adwebconnect', {}), (u'VACUUM postgres', {})]} -checks = {'': [(u'ANALYZE adwebconnect', - {}, - [(0, u'Table: auftrag', []), - (0, 'Time since last vacuum 674 d', []), - (1, u'2 tables were never analyzed: anrede/auftrag_mediadaten', [])]), - (u'ANALYZE postgres', {}, [(0, 'No never checked tables', [])]), - (u'VACUUM adwebconnect', - {}, - [(0, u'Table: auftrag', []), - (0, 'Time since last vacuum 674 d', []), - (1, u'2 tables were never vacuumed: anrede/auftrag_mediadaten', [])]), - (u'VACUUM postgres', {}, [(0, 'No never checked tables', [])])]} \ No newline at end of file +checks = { + '': [ + (u'ANALYZE adwebconnect', {'never_analyze_vacuum': (1000, 1100)}, [ + (0, u'Table: auftrag', []), + (0, 'Time since last vacuum 674 d', []), + (2, u'2 tables were never analyzed: anrede/auftrag_mediadaten (warn/crit at 16 m/18 m)', []), + ]), + (u'ANALYZE adwebconnect', {}, [ + (0, u'Table: auftrag', []), + (0, 'Time since last vacuum 674 d', []), + (1, u'2 tables were never analyzed: anrede/auftrag_mediadaten', []), + ]), + (u'ANALYZE postgres', {}, [ + (0, 'No never checked tables', []), + ]), + (u'VACUUM adwebconnect', {}, [ + (0, u'Table: auftrag', []), + (0, 'Time since last vacuum 674 d', []), + (1, u'2 tables were never vacuumed: anrede/auftrag_mediadaten', []), + ]), + (u'VACUUM postgres', {}, [ + (0, 'No never checked tables', []), + ]), +]}
5 years, 2 months
1
0
0
0
← Newer
1
...
8
9
10
11
12
13
14
...
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