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
7392 FIX mongodb_mem: Don't crash upon zero mapped bytes
by Moritz Kiemer
Module: check_mk Branch: master Commit: 6c69ae083ff1650d6f1c31195dc93f4cc617a9c5 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6c69ae083ff165…
Author: Moritz Kiemer <mo(a)mathias-kettner.de> Date: Thu Apr 4 11:30:44 2019 +0200 7392 FIX mongodb_mem: Don't crash upon zero mapped bytes CMK-1885 Change-Id: I71a6fdd8126cc8b4cd2b6a639f41961db7d12e0f --- .werks/7392 | 10 ++++++++ checks/mongodb_mem | 9 ++++--- .../datasets/mongodb_mem_2_regression.py | 30 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/.werks/7392 b/.werks/7392 new file mode 100644 index 0000000..9651d1f --- /dev/null +++ b/.werks/7392 @@ -0,0 +1,10 @@ +Title: mongodb_mem: Don't crash upon zero mapped bytes +Level: 1 +Component: checks +Compatible: compat +Edition: cre +Version: 1.6.0i1 +Date: 1554370210 +Class: fix + + diff --git a/checks/mongodb_mem b/checks/mongodb_mem index 337678e..64280c7 100644 --- a/checks/mongodb_mem +++ b/checks/mongodb_mem @@ -61,10 +61,11 @@ def check_mongodb_mem(_no_item, params, parsed): # MongoDB doc: If virtual value is significantly larger than mapped (e.g. 3 or more times), # this may indicate a memory leak. - virt_mapped_factor = parsed["virtual"] / float(parsed["mapped"]) - if virt_mapped_factor >= 3: - textfmt = "Virtual size is %.1f times the mapped size (possible memory leak)" - yield 1, textfmt % virt_mapped_factor + if parsed.get("mapped"): # present, non-zero + virt_mapped_factor = parsed["virtual"] / float(parsed["mapped"]) + if virt_mapped_factor >= 3: + textfmt = "Virtual size is %.1f times the mapped size (possible memory leak)" + yield 1, textfmt % virt_mapped_factor check_info['mongodb_mem'] = { diff --git a/tests/unit/checks/generictests/datasets/mongodb_mem_2_regression.py b/tests/unit/checks/generictests/datasets/mongodb_mem_2_regression.py new file mode 100644 index 0000000..05fdf14 --- /dev/null +++ b/tests/unit/checks/generictests/datasets/mongodb_mem_2_regression.py @@ -0,0 +1,30 @@ +# yapf: disable + + +checkname = 'mongodb_mem' + + +info = [[u'resident', u'79'], + [u'supported', u'True'], + [u'virtual', u'1021'], + [u'mappedWithJournal', u'0'], + [u'mapped', u'0'], + [u'bits', u'64'], + [u'note', u'fields', u'vary', u'by', u'platform'], + [u'page_faults', u'9']] + + +discovery = {'': [(None, {})]} + + +checks = {'': [(None, + {}, + [(0, + 'Resident usage: 79.00 MB', + [('process_resident_size', 82837504, None, None, None, None)]), + (0, + 'Virtual usage: 1021.00 MB', + [('process_virtual_size', 1070596096, None, None, None, None)]), + (0, + 'Mapped usage: 0.00 B', + [('process_mapped_size', 0, None, None, None, None)])])]} \ No newline at end of file
5 years, 6 months
1
0
0
0
mongodb_mem: modernize
by Moritz Kiemer
Module: check_mk Branch: master Commit: b93fba8a7238162906dc0d2c8b78ab54baae9784 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b93fba8a723816…
Author: Moritz Kiemer <mo(a)mathias-kettner.de> Date: Thu Apr 4 11:06:55 2019 +0200 mongodb_mem: modernize Change-Id: I1f4c5c32b069f957ce3a0ca93a2596d7a1fe09ca --- checks/mongodb_mem | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/checks/mongodb_mem b/checks/mongodb_mem index 1af6d3f..337678e 100644 --- a/checks/mongodb_mem +++ b/checks/mongodb_mem @@ -36,37 +36,40 @@ # heap_usage_bytes 65501032 -def inventory_mongodb_mem(info): - return [(None, {})] +def parse_mongodb_mem(info): + parsed = {} + for line in info: + key, value = line[0], " ".join(line[1:]) + try: + parsed[key] = int(value) + except ValueError: + parsed[key] = value + return parsed -def check_mongodb_mem(_no_item, params, info): - info_dict = {x[0]: " ".join(x[1:]) for x in info} +def check_mongodb_mem(_no_item, params, parsed): - for what in ["resident", "virtual", "mapped"]: - value_bytes = int(info_dict[what]) * 1024**2 - warn, crit = None, None - state = 0 - if "%s_levels" % what in params: - warn, crit = params["%s_levels" % what] - if value_bytes >= crit: - state = 2 - elif value_bytes >= warn: - state = 1 - yield state, "%s usage: %s" % (what.title(), get_bytes_human_readable(value_bytes)),\ - [ ("process_%s_size" % what, value_bytes, warn, crit) ] + for key in ("resident", "virtual", "mapped"): + value_bytes = parsed[key] * 1024**2 + levels = params.get("%s_levels" % key, (None, None)) + yield check_levels( + value_bytes, + "process_%s_size" % key, + levels, + human_readable_func=get_bytes_human_readable, + infoname="%s usage" % key.title()) # MongoDB doc: If virtual value is significantly larger than mapped (e.g. 3 or more times), # this may indicate a memory leak. - virtual_bytes = float(info_dict["virtual"]) - mapped_bytes = float(info_dict["mapped"]) - virt_mapped_factor = virtual_bytes / mapped_bytes + virt_mapped_factor = parsed["virtual"] / float(parsed["mapped"]) if virt_mapped_factor >= 3: - yield 1, "Virtual size is %.1f times the mapped size (Possible memory leak)" % virt_mapped_factor + textfmt = "Virtual size is %.1f times the mapped size (possible memory leak)" + yield 1, textfmt % virt_mapped_factor check_info['mongodb_mem'] = { - "inventory_function": inventory_mongodb_mem, + "parse_function": parse_mongodb_mem, + "inventory_function": discover_single, "check_function": check_mongodb_mem, "service_description": "Memory used MongoDB", "group": "mongodb_mem",
5 years, 6 months
1
0
0
0
mongodb_mem: add test
by Moritz Kiemer
Module: check_mk Branch: master Commit: e2342924a057a50dc1bf4a71f5d304963909f44f URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e2342924a057a5…
Author: Moritz Kiemer <mo(a)mathias-kettner.de> Date: Thu Apr 4 10:51:33 2019 +0200 mongodb_mem: add test Change-Id: I6b5cceeaf48433e837deb725a15c1b0689a9dd49 --- .../datasets/mongodb_mem_1_regression.py | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/unit/checks/generictests/datasets/mongodb_mem_1_regression.py b/tests/unit/checks/generictests/datasets/mongodb_mem_1_regression.py new file mode 100644 index 0000000..93553fc --- /dev/null +++ b/tests/unit/checks/generictests/datasets/mongodb_mem_1_regression.py @@ -0,0 +1,31 @@ +# yapf: disable + + +checkname = 'mongodb_mem' + + +info = [['resident', '856'], + ['supported', 'True'], + ['virtual', '6100'], + ['mappedWithJournal', '5374'], + ['mapped', '2687'], + ['bits', '64'], + ['note', 'fields', 'vary', 'by', 'platform'], + ['page_faults', '86'], + ['heap_usage_bytes', '65501032']] + + +discovery = {'': [(None, {})]} + + +checks = {'': [(None, + {}, + [(0, + 'Resident usage: 856.00 MB', + [('process_resident_size', 897581056, None, None, None, None)]), + (0, + 'Virtual usage: 5.96 GB', + [('process_virtual_size', 6396313600, None, None, None, None)]), + (0, + 'Mapped usage: 2.62 GB', + [('process_mapped_size', 2817523712, None, None, None, None)])])]} \ No newline at end of file
5 years, 6 months
1
0
0
0
Moved agent_aws to cmk lib
by Simon Betz
Module: check_mk Branch: master Commit: f13df9a4ab544e48e3aa3e23c666c961f0e09ecf URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f13df9a4ab544e…
Author: Simon Betz <si(a)mathias-kettner.de> Date: Thu Apr 4 11:07:34 2019 +0200 Moved agent_aws to cmk lib Change-Id: Ib91d0df1a0cfcd4d6bf6bbf10e5f38cc4d969e16 --- agents/special/agent_aws | 2074 +------------------------- checks/aws.include | 24 +- checks/aws_costs_and_usage | 2 - checks/aws_elb_summary | 15 +- cmk/gui/plugins/wato/datasource_programs.py | 25 +- cmk/special_agents/agent_aws.py | 2112 +++++++++++++++++++++++++++ 6 files changed, 2121 insertions(+), 2131 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=f13df9a4ab…
5 years, 6 months
1
0
0
0
Try to fix broken exception handling in remote calls
by Lars Michelsen
Module: check_mk Branch: master Commit: 42677d9ddfd64f7fbd86871eb42e98c56f03b72a URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=42677d9ddfd64f…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Apr 4 13:09:22 2019 +0200 Try to fix broken exception handling in remote calls Change-Id: Iecce3418c377838409bd5e9dd2a418aa7a7fb628 --- agents/windows/it/remote.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/agents/windows/it/remote.py b/agents/windows/it/remote.py index cc63851..8788c01 100644 --- a/agents/windows/it/remote.py +++ b/agents/windows/it/remote.py @@ -67,24 +67,27 @@ def wait_agent(): def actual_output(write_config, wait_agent): if platform.system() == 'Windows': # Run agent and yield telnet output. + telnet, p = None, None try: save_cwd = os.getcwd() os.chdir(remotedir) p = subprocess.Popen([agent_exe, 'adhoc']) + # Override wait_agent in tests to wait for async processes to start. wait_agent() + telnet = telnetlib.Telnet(host, port) # nosec yield telnet.read_all().splitlines() finally: - try: + if telnet: telnet.close() + + if p: p.terminate() - # Possibly wait for async processes to stop. - wait_agent() - # Thrown if something goes wrong before variable assigment - except UnboundLocalError as e: - sys.stderr.write('%s\n' % str(e)) - assert 0, '%s' % str(e) + + # Possibly wait for async processes to stop. + wait_agent() + os.chdir(save_cwd) else: # Not on Windows, test run remotely, nothing to be done.
5 years, 6 months
1
0
0
0
Simplify test_data_sources_of_hosts test
by Lars Michelsen
Module: check_mk Branch: master Commit: e6fa58eac7d5b082c0ca3f52b22d9ca42b79e8f5 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e6fa58eac7d5b0…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Apr 4 12:50:04 2019 +0200 Simplify test_data_sources_of_hosts test Change-Id: I1cc8762f410e8666f1befa6be1b9be3d310b2df5 --- tests/unit/cmk_base/test_data_sources_unit.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/unit/cmk_base/test_data_sources_unit.py b/tests/unit/cmk_base/test_data_sources_unit.py index 9ce3420..9da2bee 100644 --- a/tests/unit/cmk_base/test_data_sources_unit.py +++ b/tests/unit/cmk_base/test_data_sources_unit.py @@ -238,6 +238,9 @@ def test_data_sources_of_hosts(clear_config_caches, monkeypatch, hostname, setti config.get_config_cache().initialize() + print config.get_config_cache.get_host_config(hostname).is_piggyback_host + + sources = cmk_base.data_sources.DataSources(hostname, "127.0.0.1") source_names = [s.__class__.__name__ for s in sources.get_data_sources()] assert settings["sources"] == source_names, "Wrong sources for %s" % hostname
5 years, 6 months
1
0
0
0
Simplify test_data_sources_of_hosts test
by Lars Michelsen
Module: check_mk Branch: master Commit: 35203fa70bf4f01ef806a3d19d01222a3d68b8a5 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=35203fa70bf4f0…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Apr 4 12:48:44 2019 +0200 Simplify test_data_sources_of_hosts test Change-Id: Id5b46bdb4b8cccdc48596a6f589c8ad714f10178 --- tests/unit/cmk_base/test_data_sources_unit.py | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tests/unit/cmk_base/test_data_sources_unit.py b/tests/unit/cmk_base/test_data_sources_unit.py index 4bc3e7b..9ce3420 100644 --- a/tests/unit/cmk_base/test_data_sources_unit.py +++ b/tests/unit/cmk_base/test_data_sources_unit.py @@ -158,8 +158,9 @@ def clear_config_caches(monkeypatch): monkeypatch.setattr(cmk_base, "runtime_cache", cmk_base.caching.CacheManager()) -def test_data_sources_of_hosts(clear_config_caches, monkeypatch): - hosts = [ +(a)pytest.mark.parametrize( + "hostname,settings", + [ # Configs from 1.4 ("agent-host-14", { "tags": "lan|cmk-agent|ip-v4|tcp|ip-v4-only|prod", @@ -218,15 +219,10 @@ def test_data_sources_of_hosts(clear_config_caches, monkeypatch): "tags": "lan|ip-v4|no-snmp|tcp|ip-v4-only|special-agents|prod", "sources": ['SpecialAgentDataSource', 'PiggyBackDataSource'], }), - ] - - all_hosts = [("%s|%s" % (name, h["tags"])) for name, h in hosts] - monkeypatch.setattr(config, "all_hosts", all_hosts) - - changed_hosts_paths = copy.deepcopy(config.host_paths) - for name, _h in hosts: - changed_hosts_paths[name] = "/" - monkeypatch.setattr(config, "host_paths", changed_hosts_paths) + ]) +def test_data_sources_of_hosts(clear_config_caches, monkeypatch, hostname, settings): + monkeypatch.setattr(config, "all_hosts", ["%s|%s" % (hostname, settings["tags"])]) + monkeypatch.setattr(config, "host_paths", {hostname: "/"}) monkeypatch.setattr(config, "datasource_programs", [ ('echo 1', [], ['ds-host-14', 'all-agents-host', 'all-special-host'], {}), @@ -242,8 +238,6 @@ def test_data_sources_of_hosts(clear_config_caches, monkeypatch): config.get_config_cache().initialize() - for hostname, host_attrs in hosts: - sources = cmk_base.data_sources.DataSources(hostname, "127.0.0.1") - source_names = [s.__class__.__name__ for s in sources.get_data_sources()] - assert host_attrs["sources"] == source_names, \ - "Wrong sources for %s" % hostname + sources = cmk_base.data_sources.DataSources(hostname, "127.0.0.1") + source_names = [s.__class__.__name__ for s in sources.get_data_sources()] + assert settings["sources"] == source_names, "Wrong sources for %s" % hostname
5 years, 6 months
1
0
0
0
Moved unit test to correct place
by Lars Michelsen
Module: check_mk Branch: master Commit: 352ae03509776d09bf45ead8d931b056e97527af URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=352ae03509776d…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Apr 4 12:20:41 2019 +0200 Moved unit test to correct place Change-Id: I28f771e219dcad7ff29dc9fd4b155fe09c443e80 --- tests/integration/cmk_base/test_data_sources.py | 107 ------------------------ tests/unit/cmk_base/test_data_sources_unit.py | 104 +++++++++++++++++++++++ 2 files changed, 104 insertions(+), 107 deletions(-) diff --git a/tests/integration/cmk_base/test_data_sources.py b/tests/integration/cmk_base/test_data_sources.py index e1a4401..12c256e 100644 --- a/tests/integration/cmk_base/test_data_sources.py +++ b/tests/integration/cmk_base/test_data_sources.py @@ -450,110 +450,3 @@ def test_automation_diag_host_caching(test_cfg, monkeypatch): # Keepalive check # Keepalive discovery # TODO: Check the caching age for cluster hosts - -# -# UNIT TESTS -# - - -# Automatically refresh caches for each test -(a)pytest.fixture(scope="function") -def clear_config_caches(monkeypatch): - import cmk_base - import cmk_base.caching - monkeypatch.setattr(cmk_base, "config_cache", cmk_base.caching.CacheManager()) - monkeypatch.setattr(cmk_base, "runtime_cache", cmk_base.caching.CacheManager()) - - -def test_data_sources_of_hosts(clear_config_caches, monkeypatch): - hosts = [ - # Configs from 1.4 - ("agent-host-14", { - "tags": "lan|cmk-agent|ip-v4|tcp|ip-v4-only|prod", - "sources": ['TCPDataSource', 'PiggyBackDataSource'], - }), - ("ds-host-14", { - "tags": "lan|cmk-agent|ip-v4|tcp|ip-v4-only|prod", - "sources": ['DSProgramDataSource', 'PiggyBackDataSource'], - }), - ("special-host-14", { - "tags": "lan|cmk-agent|ip-v4|tcp|ip-v4-only|prod", - "sources": ['SpecialAgentDataSource', 'PiggyBackDataSource'], - }), - ("ping-host-14", { - "tags": "lan|ip-v4|ping|ip-v4-only|prod", - "sources": ['PiggyBackDataSource'], - }), - ("snmp-host-14", { - "tags": "lan|ip-v4|snmp|snmp-only|ip-v4-only|prod", - "sources": ['SNMPDataSource', 'PiggyBackDataSource'], - }), - ("snmpv1-host-14", { - "tags": "lan|ip-v4|snmp|snmp-v1|ip-v4-only|prod", - "sources": ['SNMPDataSource', 'PiggyBackDataSource'], - }), - ("dual-host-14", { - "tags": "lan|ip-v4|snmp|tcp|ip-v4-only|prod|snmp-tcp", - "sources": ['TCPDataSource', 'SNMPDataSource', 'PiggyBackDataSource'], - }), - # From current WATO - ("agent-host", { - "tags": "lan|ip-v4|cmk-agent|no-snmp|tcp|ip-v4-only|prod", - "sources": ['TCPDataSource', 'PiggyBackDataSource'], - }), - ("ping-host", { - "tags": "lan|ip-v4|ping|no-snmp|ip-v4-only|no-agent|prod", - "sources": ['PiggyBackDataSource'], - }), - ("snmp-host", { - "tags": "lan|ip-v4|snmp|snmp-v2|ip-v4-only|no-agent|prod", - "sources": ['SNMPDataSource', 'PiggyBackDataSource'], - }), - ("snmpv1-host", { - "tags": "lan|ip-v4|snmp|snmp-v1|ip-v4-only|no-agent|prod", - "sources": ['SNMPDataSource', 'PiggyBackDataSource'], - }), - ("dual-host", { - "tags": "lan|ip-v4|cmk-agent|snmp|snmp-v2|ip-v4-only|tcp|prod", - "sources": ['TCPDataSource', 'SNMPDataSource', 'PiggyBackDataSource'], - }), - ("all-agents-host", { - "tags": "lan|all-agents|ip-v4|no-snmp|tcp|ip-v4-only|prod", - "sources": ['DSProgramDataSource', 'SpecialAgentDataSource', 'PiggyBackDataSource'], - }), - ("all-special-host", { - "tags": "lan|ip-v4|no-snmp|tcp|ip-v4-only|special-agents|prod", - "sources": ['SpecialAgentDataSource', 'PiggyBackDataSource'], - }), - ] - - import cmk_base.data_sources - - all_hosts = [("%s|%s" % (name, h["tags"])) for name, h in hosts] - monkeypatch.setattr(config, "all_hosts", all_hosts) - - import copy - changed_hosts_paths = copy.deepcopy(config.host_paths) - for name, _h in hosts: - changed_hosts_paths[name] = "/" - monkeypatch.setattr(config, "host_paths", changed_hosts_paths) - - monkeypatch.setattr(config, "datasource_programs", [ - ('echo 1', [], ['ds-host-14', 'all-agents-host', 'all-special-host'], {}), - ]) - - monkeypatch.setitem(config.special_agents, "jolokia", [ - ({}, [], [ - 'special-host-14', - 'all-agents-host', - 'all-special-host', - ], {}), - ]) - - config.get_config_cache().initialize() - - for hostname, host_attrs in hosts: - sources = cmk_base.data_sources.DataSources(hostname, "127.0.0.1") - source_names = [s.__class__.__name__ for s in sources.get_data_sources()] - assert host_attrs["sources"] == source_names, \ - "Wrong sources for %s" % hostname diff --git a/tests/unit/cmk_base/test_data_sources_unit.py b/tests/unit/cmk_base/test_data_sources_unit.py index 7d7bf91..4bc3e7b 100644 --- a/tests/unit/cmk_base/test_data_sources_unit.py +++ b/tests/unit/cmk_base/test_data_sources_unit.py @@ -1,5 +1,11 @@ +# pylint: disable=redefined-outer-name + +import copy import pytest +import cmk_base +import cmk_base.caching +import cmk_base.data_sources import cmk_base.data_sources.abstract import cmk_base.data_sources.programs import cmk_base.data_sources.snmp @@ -143,3 +149,101 @@ def test_get_command_line_and_stdin(monkeypatch, info_func_result, expected): command_line, command_stdin = ds._get_command_line_and_stdin() assert command_line == agent_prefix + expected[0] assert command_stdin == expected[1] + + +# Automatically refresh caches for each test +(a)pytest.fixture(scope="function") +def clear_config_caches(monkeypatch): + monkeypatch.setattr(cmk_base, "config_cache", cmk_base.caching.CacheManager()) + monkeypatch.setattr(cmk_base, "runtime_cache", cmk_base.caching.CacheManager()) + + +def test_data_sources_of_hosts(clear_config_caches, monkeypatch): + hosts = [ + # Configs from 1.4 + ("agent-host-14", { + "tags": "lan|cmk-agent|ip-v4|tcp|ip-v4-only|prod", + "sources": ['TCPDataSource', 'PiggyBackDataSource'], + }), + ("ds-host-14", { + "tags": "lan|cmk-agent|ip-v4|tcp|ip-v4-only|prod", + "sources": ['DSProgramDataSource', 'PiggyBackDataSource'], + }), + ("special-host-14", { + "tags": "lan|cmk-agent|ip-v4|tcp|ip-v4-only|prod", + "sources": ['SpecialAgentDataSource', 'PiggyBackDataSource'], + }), + ("ping-host-14", { + "tags": "lan|ip-v4|ping|ip-v4-only|prod", + "sources": ['PiggyBackDataSource'], + }), + ("snmp-host-14", { + "tags": "lan|ip-v4|snmp|snmp-only|ip-v4-only|prod", + "sources": ['SNMPDataSource', 'PiggyBackDataSource'], + }), + ("snmpv1-host-14", { + "tags": "lan|ip-v4|snmp|snmp-v1|ip-v4-only|prod", + "sources": ['SNMPDataSource', 'PiggyBackDataSource'], + }), + ("dual-host-14", { + "tags": "lan|ip-v4|snmp|tcp|ip-v4-only|prod|snmp-tcp", + "sources": ['TCPDataSource', 'SNMPDataSource', 'PiggyBackDataSource'], + }), + # From current WATO + ("agent-host", { + "tags": "lan|ip-v4|cmk-agent|no-snmp|tcp|ip-v4-only|prod", + "sources": ['TCPDataSource', 'PiggyBackDataSource'], + }), + ("ping-host", { + "tags": "lan|ip-v4|ping|no-snmp|ip-v4-only|no-agent|prod", + "sources": ['PiggyBackDataSource'], + }), + ("snmp-host", { + "tags": "lan|ip-v4|snmp|snmp-v2|ip-v4-only|no-agent|prod", + "sources": ['SNMPDataSource', 'PiggyBackDataSource'], + }), + ("snmpv1-host", { + "tags": "lan|ip-v4|snmp|snmp-v1|ip-v4-only|no-agent|prod", + "sources": ['SNMPDataSource', 'PiggyBackDataSource'], + }), + ("dual-host", { + "tags": "lan|ip-v4|cmk-agent|snmp|snmp-v2|ip-v4-only|tcp|prod", + "sources": ['TCPDataSource', 'SNMPDataSource', 'PiggyBackDataSource'], + }), + ("all-agents-host", { + "tags": "lan|all-agents|ip-v4|no-snmp|tcp|ip-v4-only|prod", + "sources": ['DSProgramDataSource', 'SpecialAgentDataSource', 'PiggyBackDataSource'], + }), + ("all-special-host", { + "tags": "lan|ip-v4|no-snmp|tcp|ip-v4-only|special-agents|prod", + "sources": ['SpecialAgentDataSource', 'PiggyBackDataSource'], + }), + ] + + all_hosts = [("%s|%s" % (name, h["tags"])) for name, h in hosts] + monkeypatch.setattr(config, "all_hosts", all_hosts) + + changed_hosts_paths = copy.deepcopy(config.host_paths) + for name, _h in hosts: + changed_hosts_paths[name] = "/" + monkeypatch.setattr(config, "host_paths", changed_hosts_paths) + + monkeypatch.setattr(config, "datasource_programs", [ + ('echo 1', [], ['ds-host-14', 'all-agents-host', 'all-special-host'], {}), + ]) + + monkeypatch.setitem(config.special_agents, "jolokia", [ + ({}, [], [ + 'special-host-14', + 'all-agents-host', + 'all-special-host', + ], {}), + ]) + + config.get_config_cache().initialize() + + for hostname, host_attrs in hosts: + sources = cmk_base.data_sources.DataSources(hostname, "127.0.0.1") + source_names = [s.__class__.__name__ for s in sources.get_data_sources()] + assert host_attrs["sources"] == source_names, \ + "Wrong sources for %s" % hostname
5 years, 6 months
1
0
0
0
Fixed issue in recent refactoring
by Lars Michelsen
Module: check_mk Branch: master Commit: 815d6e8c985089e6972525ef8b52a257acf71662 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=815d6e8c985089…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Thu Apr 4 12:58:26 2019 +0200 Fixed issue in recent refactoring Change-Id: I8f98916659b62d3f9f5eb81ff4a98828560ef6a5 --- cmk_base/data_sources/__init__.py | 4 ++-- tests/unit/cmk_base/test_data_sources_unit.py | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cmk_base/data_sources/__init__.py b/cmk_base/data_sources/__init__.py index bef1f14..60f7d5c 100644 --- a/cmk_base/data_sources/__init__.py +++ b/cmk_base/data_sources/__init__.py @@ -98,7 +98,7 @@ class DataSources(object): self._ipaddress = ipaddress config_cache = config.get_config_cache() - self._host_config = config.HostConfig(config_cache, hostname) + self._host_config = config_cache.get_host_config(hostname) self._initialize_data_sources() @@ -134,7 +134,7 @@ class DataSources(object): source.set_main_agent_data_source() self._add_source(source) - if self._host_config.is_piggyback_host: + if "no-piggyback" not in self._host_config.tags: self._add_source(PiggyBackDataSource(self._hostname, self._ipaddress)) def _initialize_snmp_data_sources(self): diff --git a/tests/unit/cmk_base/test_data_sources_unit.py b/tests/unit/cmk_base/test_data_sources_unit.py index 9da2bee..9ce3420 100644 --- a/tests/unit/cmk_base/test_data_sources_unit.py +++ b/tests/unit/cmk_base/test_data_sources_unit.py @@ -238,9 +238,6 @@ def test_data_sources_of_hosts(clear_config_caches, monkeypatch, hostname, setti config.get_config_cache().initialize() - print config.get_config_cache.get_host_config(hostname).is_piggyback_host - - sources = cmk_base.data_sources.DataSources(hostname, "127.0.0.1") source_names = [s.__class__.__name__ for s in sources.get_data_sources()] assert settings["sources"] == source_names, "Wrong sources for %s" % hostname
5 years, 6 months
1
0
0
0
[CMK-1850] - functionality of exchange_msi_files target had been removed as deprecated and even dangerous
by Sergey Kipnis
Module: check_mk Branch: master Commit: 28b48ebac21da0616568e2083e9d72bd9356984e URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=28b48ebac21da0…
Author: Sergey Kipnis <sk(a)mathias-kettner.de> Date: Thu Apr 4 11:18:43 2019 +0200 [CMK-1850] - functionality of exchange_msi_files target had been removed as deprecated and even dangerous Change-Id: I02d10eec1885cef344831072acc7e360933be964 --- agents/windows/msibuild/Makefile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/agents/windows/msibuild/Makefile b/agents/windows/msibuild/Makefile index 053dc48..e336a5a 100755 --- a/agents/windows/msibuild/Makefile +++ b/agents/windows/msibuild/Makefile @@ -32,7 +32,6 @@ all: exchange_msi_files clean: rm -rf $(MSITOOLS) - rm -f check_mk_agent.msi rm -rf work sources rm -f .gsf-save-* @@ -48,10 +47,7 @@ msibuild: rm msibuild msiinfo ln -s $(MSITOOLS)/msibuild $(MSITOOLS)/msiinfo . - +# with new agent we do not need to update vanilla container +# nothing to do, but target left for the future changes and +# for updating msibuild exchange_msi_files: msibuild - mkdir -p work sources - cp ../check_mk_agent.exe ../check_mk_agent-64.exe ../check_mk.example.ini sources - LD_LIBRARY_PATH=$$(pwd)/msitools-0.94/libmsi/.libs \ - ./msi-update -v vanilla_container.msi sources $(BUILD_VERSION) $(CHECK_MK_VERSION) - rm -rf work sources
5 years, 6 months
1
0
0
0
← Newer
1
...
44
45
46
47
48
49
50
...
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