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
March 2018
----- 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
10 participants
326 discussions
Start a n
N
ew thread
5901 FIX Fixed broken "Check_MK Discovery" service when using Nagios core
by Lars Michelsen
Module: check_mk Branch: master Commit: 220b5fd472798ce6764406ae8247806c273aab1f URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=220b5fd472798c…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Tue Mar 13 15:15:27 2018 +0100 5901 FIX Fixed broken "Check_MK Discovery" service when using Nagios core Previous 1.5.x releases were using outdated check_mk_templates.cfg which resulted in a wrong command being executed for the discovery service. Change-Id: Ia5e0ab379c71c07ab212cb21758de45e0b68f831 --- .werks/5901 | 11 + Makefile | 2 - check_mk_templates.cfg | 432 --------------------- .../skel/etc/nagios/conf.d/check_mk_templates.cfg | 14 +- 4 files changed, 17 insertions(+), 442 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=220b5fd472…
6 years, 6 months
1
0
0
0
Exclude build artefacts from git permission test
by Lars Michelsen
Module: check_mk Branch: master Commit: 8dbf98fd236f59f3abf983397e4d52c4bd86ae38 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8dbf98fd236f59…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Tue Mar 13 17:29:29 2018 +0100 Exclude build artefacts from git permission test Change-Id: Ie9db87bfd9be67351938fbc49bf6880a5f0f51f7 --- tests/git/test_permissions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/git/test_permissions.py b/tests/git/test_permissions.py index e67eebc..fcd331b 100644 --- a/tests/git/test_permissions.py +++ b/tests/git/test_permissions.py @@ -32,7 +32,7 @@ permissions = [ ('enterprise/bin/*', is_executable, []), ('enterprise/active_checks/*', is_executable, []), ('enterprise/agents/bakery/*', is_not_executable, []), - ('enterprise/agents/plugins/*', is_executable, ["chroot_version", "Makefile", "pyinstaller-deps.make"]), + ('enterprise/agents/plugins/*', is_executable, ["chroot_version", "Makefile", "pyinstaller-deps.make", "chroot"]), ('enterprise/alert_handlers/*', is_executable, []), ('enterprise/alert_handlers/*', is_executable, []), ]
6 years, 6 months
1
0
0
0
Equalize IP lookup behaviour of check/discovery/inventory services
by Lars Michelsen
Module: check_mk Branch: master Commit: 46338d867135728d2ab07712f38a7ecff895a0bc URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=46338d86713572…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Tue Mar 13 13:42:07 2018 +0100 Equalize IP lookup behaviour of check/discovery/inventory services Change-Id: Ie5f9cf0a8a83b84f4000e15df82cec4e8cc5722f --- cmk_base/checking.py | 11 +++++++++++ cmk_base/core_nagios.py | 2 +- cmk_base/data_sources/abstract.py | 7 ++++--- cmk_base/discovery.py | 7 ++----- cmk_base/exceptions.py | 5 +++++ cmk_base/ip_lookup.py | 4 ++-- cmk_base/modes/check_mk.py | 9 +-------- 7 files changed, 26 insertions(+), 19 deletions(-) diff --git a/cmk_base/checking.py b/cmk_base/checking.py index b218e69..e7fd628 100644 --- a/cmk_base/checking.py +++ b/cmk_base/checking.py @@ -42,6 +42,7 @@ import cmk_base.console as console import cmk_base.config as config import cmk_base.checks as checks import cmk_base.snmp as snmp +import cmk_base.ip_lookup as ip_lookup import cmk_base.data_sources as data_sources import cmk_base.item_state as item_state import cmk_base.core as core @@ -86,6 +87,12 @@ def do_check(hostname, ipaddress, only_check_plugin_names=None): state, output, perfdata = 0, [], [] try: + # In case of keepalive we always have an ipaddress (can be 0.0.0.0 or :: when + # address is unknown). When called as non keepalive ipaddress may be None or + # is already an address (2nd argument) + if ipaddress is None and not config.is_cluster(hostname): + ipaddress = ip_lookup.lookup_ip_address(hostname) + item_state.load(hostname) sources = data_sources.DataSources(hostname, ipaddress) @@ -114,6 +121,10 @@ def do_check(hostname, ipaddress, only_check_plugin_names=None): except MKTimeout: raise + except MKIPAddressLookupError, e: + output.append("%s" % e) + state = max(state, exit_spec.get("connection", 2)) + except MKGeneralException, e: if cmk.debug.enabled(): raise diff --git a/cmk_base/core_nagios.py b/cmk_base/core_nagios.py index 2e58a0e..e167a64 100644 --- a/cmk_base/core_nagios.py +++ b/cmk_base/core_nagios.py @@ -435,7 +435,7 @@ define service { if host_attrs["address"] in [ "0.0.0.0", "::" ]: command_name = "check-mk-custom" - command = command_name + "!echo \"Failed to lookup IP address and no explicit IP address configured\" && exit 3" + command = command_name + "!echo \"CRIT - Failed to lookup IP address and no explicit IP address configured\" && exit 2" custom_commands_to_define.add(command_name) else: command = "check_mk_active-%s!%s" % (acttype, args) diff --git a/cmk_base/data_sources/abstract.py b/cmk_base/data_sources/abstract.py index 1818772..2fa932b 100644 --- a/cmk_base/data_sources/abstract.py +++ b/cmk_base/data_sources/abstract.py @@ -45,7 +45,7 @@ import cmk_base.piggyback as piggyback import cmk_base.checks as checks import cmk_base.check_api as check_api from cmk_base.exceptions import MKSkipCheck, MKAgentError, MKEmptyAgentData, MKSNMPError, \ - MKParseFunctionError, MKTimeout + MKParseFunctionError, MKTimeout, MKIPAddressLookupError from .host_sections import HostSections @@ -317,10 +317,10 @@ class DataSource(object): def _verify_ipaddress(self): if not self._ipaddress: - raise MKAgentError("Host as no IP address configured.") + raise MKIPAddressLookupError("Host as no IP address configured.") if self._ipaddress in [ "0.0.0.0", "::" ]: - raise MKAgentError("Failed to lookup IP address and no explicit IP address configured") + raise MKIPAddressLookupError("Failed to lookup IP address and no explicit IP address configured") def set_max_cachefile_age(self, max_cachefile_age): @@ -366,6 +366,7 @@ class DataSource(object): status = exit_spec.get("empty_output", 2) elif isinstance(self._exception, MKAgentError) \ + or isinstance(self._exception, MKIPAddressLookupError) \ or isinstance(self._exception, MKSNMPError): status = exit_spec.get("connection", 2) diff --git a/cmk_base/discovery.py b/cmk_base/discovery.py index 3024bb6..e372d28 100644 --- a/cmk_base/discovery.py +++ b/cmk_base/discovery.py @@ -308,11 +308,8 @@ def check_discovery(hostname, ipaddress): try: # In case of keepalive discovery we always have an ipaddress. When called as non keepalive # ipaddress is always None - if ipaddress is None: - if config.is_cluster(hostname): - ipaddress = None - else: - ipaddress = ip_lookup.lookup_ip_address(hostname) + if ipaddress is None and not config.is_cluster(hostname): + ipaddress = ip_lookup.lookup_ip_address(hostname) sources = _get_sources_for_discovery(hostname, ipaddress, check_plugin_names=None, do_snmp_scan=params["inventory_check_do_scan"], diff --git a/cmk_base/exceptions.py b/cmk_base/exceptions.py index 10d387f..1456bd5 100644 --- a/cmk_base/exceptions.py +++ b/cmk_base/exceptions.py @@ -27,6 +27,8 @@ # TODO: Inherit from cmk.MKGeneralException? # TODO: Cleanup self.reason to use .args of standard exceptions +from cmk.exceptions import MKGeneralException as _MKGeneralException + class MKAgentError(Exception): def __init__(self, reason): super(MKAgentError, self).__init__(reason) @@ -37,6 +39,9 @@ class MKAgentError(Exception): return self.reason +class MKIPAddressLookupError(_MKGeneralException): + pass + class MKEmptyAgentData(MKAgentError): pass diff --git a/cmk_base/ip_lookup.py b/cmk_base/ip_lookup.py index f43a4fa..d061ed0 100644 --- a/cmk_base/ip_lookup.py +++ b/cmk_base/ip_lookup.py @@ -33,7 +33,7 @@ import cmk_base import cmk_base.console as console import cmk_base.config as config import cmk_base.rulesets as rulesets -from cmk.exceptions import MKGeneralException +from cmk_base.exceptions import MKIPAddressLookupError _fake_dns = False _enforce_localhost = False @@ -138,7 +138,7 @@ def cached_dns_lookup(hostname, family): return cached_ip else: cache[cache_id] = None - raise MKGeneralException( + raise MKIPAddressLookupError( "Failed to lookup IPv%d address of %s via DNS: %s" % (family, hostname, e)) diff --git a/cmk_base/modes/check_mk.py b/cmk_base/modes/check_mk.py index fe53266..14717be 100644 --- a/cmk_base/modes/check_mk.py +++ b/cmk_base/modes/check_mk.py @@ -1524,14 +1524,7 @@ def mode_check(options, args): if len(args) == 2: ipaddress = args[1] else: - if config.is_cluster(hostname): - ipaddress = None - else: - try: - ipaddress = ip_lookup.lookup_ip_address(hostname) - except: - console.error("Cannot resolve hostname '%s'.\n" % hostname) - return 2 + ipaddress = None return checking.do_check(hostname, ipaddress, options.get("checks"))
6 years, 6 months
1
0
0
0
Removed unconfigurable static flag inventory_pprint_output
by Lars Michelsen
Module: check_mk Branch: master Commit: dd9d0820401bc95f0deb74ecbbcc6630452689a7 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dd9d0820401bc9…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Tue Mar 13 18:14:09 2018 +0100 Removed unconfigurable static flag inventory_pprint_output Change-Id: I1ba1954766963a2112f622e531d1baf07ce66287 --- cmk_base/inventory.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmk_base/inventory.py b/cmk_base/inventory.py index 4b6e564..1126979 100644 --- a/cmk_base/inventory.py +++ b/cmk_base/inventory.py @@ -57,8 +57,6 @@ import cmk_base.data_sources as data_sources inventory_output_dir = cmk.paths.var_dir + "/inventory" inventory_archive_dir = cmk.paths.var_dir + "/inventory_archive" status_data_dir = cmk.paths.tmp_dir + "/status_data" -# TODO: This is not configurable. Drop the flag? -inventory_pprint_output = False #. # .--Inventory-----------------------------------------------------------. @@ -320,7 +318,7 @@ def _save_inventory_tree(hostname, inventory_tree): if not os.path.exists(arcdir): os.makedirs(arcdir) os.rename(filepath, arcdir + ("/%d" % old_time)) - inventory_tree.save_to(inventory_output_dir, hostname, pretty=inventory_pprint_output) + inventory_tree.save_to(inventory_output_dir, hostname) else: if os.path.exists(filepath): # Remove empty inventory files. Important for host inventory icon @@ -337,7 +335,7 @@ def _save_status_data_tree(hostname, status_data_tree): filepath = "%s/%s" % (status_data_dir, hostname) if status_data_tree and not status_data_tree.is_empty(): - status_data_tree.save_to(status_data_dir, hostname, pretty=inventory_pprint_output) + status_data_tree.save_to(status_data_dir, hostname) else: if os.path.exists(filepath): # Remove empty status data files.
6 years, 6 months
1
0
0
0
Abstracted exception handling away from "Check_MK *" functions
by Lars Michelsen
Module: check_mk Branch: master Commit: f7c0d0404531cdb7513d2bebc7dce616422b6aaf URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f7c0d0404531cd…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Tue Mar 13 15:20:09 2018 +0100 Abstracted exception handling away from "Check_MK *" functions * The result handling is now done in a separate layer, realized as decorator wrapper (checking.handle_check_mk_check_result()) * The wrapper is caring about result text formating and consistent exception handling (including crash reports) Change-Id: I9fbaf4596e501f970141974d04920c408c19a07f --- cmk_base/checking.py | 158 +++++++++++++++++++++++--------------- cmk_base/discovery.py | 183 ++++++++++++++++++--------------------------- cmk_base/inventory.py | 109 ++++++++++++--------------- cmk_base/modes/check_mk.py | 2 +- 4 files changed, 220 insertions(+), 232 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=f7c0d04045…
6 years, 6 months
1
0
0
0
Win-agent: const correctness fixes 3
by Jukka Aro
Module: check_mk Branch: master Commit: 6eeeb8814b143470fbcf03f25f2d03a88995c9ea URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6eeeb8814b1434…
Author: Jukka Aro <ja(a)mathias-kettner.de> Date: Tue Mar 13 16:53:00 2018 +0100 Win-agent: const correctness fixes 3 Separator char is known at section object initialization time -> there is no reason to have it as a non-const member. Just initialize it once and correctly. --- agents/windows/Section.cc | 6 ++++-- agents/windows/Section.h | 12 ++---------- agents/windows/SectionManager.cc | 11 +++++------ agents/windows/build_version | 2 +- agents/windows/sections/SectionDF.cc | 4 +--- agents/windows/sections/SectionFileinfo.cc | 7 +++---- agents/windows/sections/SectionGroup.cc | 8 ++++---- agents/windows/sections/SectionGroup.h | 4 ++-- agents/windows/sections/SectionPS.cc | 6 ++---- agents/windows/sections/SectionPerfcounter.cc | 6 ++---- agents/windows/sections/SectionSkype.cc | 3 +-- agents/windows/sections/SectionWMI.cc | 4 +--- 12 files changed, 28 insertions(+), 45 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=6eeeb8814b…
6 years, 6 months
1
0
0
0
Disentangle the kind of the filter and its operation.
by Sven Panne
Module: check_mk Branch: master Commit: 2d15219e0ef618a1d3fd6d4b62d73594cb460187 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2d15219e0ef618…
Author: Sven Panne <sp(a)mathias-kettner.de> Date: Tue Mar 13 15:53:11 2018 +0100 Disentangle the kind of the filter and its operation. Change-Id: I4238f2501250288abaeb12ad0d09a80d09bffe95 --- livestatus/src/AndingFilter.cc | 19 ++++++++--- livestatus/src/AndingFilter.h | 6 ++-- livestatus/src/AttributeListAsIntColumn.cc | 5 +-- livestatus/src/AttributeListAsIntColumn.h | 5 +-- livestatus/src/AttributeListColumn.cc | 5 +-- livestatus/src/AttributeListColumn.h | 5 +-- livestatus/src/BlobColumn.cc | 3 +- livestatus/src/BlobColumn.h | 5 +-- livestatus/src/Column.h | 5 +-- livestatus/src/ColumnFilter.cc | 8 ++--- livestatus/src/ColumnFilter.h | 7 +++-- livestatus/src/CustomVarsDictColumn.cc | 5 +-- livestatus/src/CustomVarsDictColumn.h | 5 +-- livestatus/src/CustomVarsDictFilter.cc | 7 +++-- livestatus/src/CustomVarsDictFilter.h | 4 +-- livestatus/src/DoubleColumn.cc | 5 +-- livestatus/src/DoubleColumn.h | 5 +-- livestatus/src/DoubleFilter.cc | 8 ++--- livestatus/src/DoubleFilter.h | 6 ++-- livestatus/src/Filter.cc | 47 +++------------------------ livestatus/src/Filter.h | 18 +++-------- livestatus/src/IntColumn.cc | 5 +-- livestatus/src/IntColumn.h | 5 +-- livestatus/src/IntFilter.cc | 8 ++--- livestatus/src/IntFilter.h | 4 +-- livestatus/src/ListColumn.cc | 5 +-- livestatus/src/ListColumn.h | 5 +-- livestatus/src/ListFilter.cc | 8 ++--- livestatus/src/ListFilter.h | 4 +-- livestatus/src/NullColumn.cc | 4 +-- livestatus/src/NullColumn.h | 5 +-- livestatus/src/OringFilter.cc | 19 ++++++++--- livestatus/src/OringFilter.h | 6 ++-- livestatus/src/Query.cc | 49 ++++++++++++++--------------- livestatus/src/Query.h | 5 ++- livestatus/src/ServiceGroupMembersColumn.cc | 5 +-- livestatus/src/ServiceGroupMembersColumn.h | 5 +-- livestatus/src/StatsColumn.cc | 3 +- livestatus/src/StringColumn.cc | 5 +-- livestatus/src/StringColumn.h | 5 +-- livestatus/src/StringFilter.cc | 8 ++--- livestatus/src/StringFilter.h | 6 ++-- livestatus/src/TimeColumn.cc | 5 +-- livestatus/src/TimeColumn.h | 5 +-- livestatus/src/TimeFilter.cc | 8 ++--- livestatus/src/TimeFilter.h | 4 +-- 46 files changed, 187 insertions(+), 187 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=2d15219e0e…
6 years, 6 months
1
0
0
0
Complete make format target for Windows agent src
by Jukka Aro
Module: check_mk Branch: master Commit: bf055c92138690ab7c59a9fc94428cb8536a365a URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bf055c92138690…
Author: Jukka Aro <ja(a)mathias-kettner.de> Date: Tue Mar 13 15:21:14 2018 +0100 Complete make format target for Windows agent src The subdirectories sections, test and test/sections were completely missing and consequently ignored by clang-format. --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b0469ab..ada9037 100644 --- a/Makefile +++ b/Makefile @@ -115,7 +115,10 @@ HEAL_SPACES_IN := checkman/* cmk_base/* checks/* notifications/* inventory/* managed/web/plugins/*/*/*.py) FILES_TO_FORMAT := $(wildcard $(addprefix agents/,*.cc *.c *.h)) \ - $(wildcard $(addprefix agents/windows/,*.cc *.c *.h)) \ + $(wildcard $(addprefix agents/windows/,*.cc *.h)) \ + $(wildcard $(addprefix agents/windows/sections/,*.cc *.h)) \ + $(wildcard $(addprefix agents/windows/test/,*.cc *.h)) \ + $(wildcard $(addprefix agents/windows/test/sections,*.cc *.h)) \ $(wildcard $(addprefix livestatus/api/c++/,*.cc *.h)) \ $(wildcard $(addprefix livestatus/src/,*.cc *.h)) \ $(wildcard $(addprefix bin/,*.cc *.c *.h)) \
6 years, 6 months
1
0
0
0
Clang-format C++ code
by Jukka Aro
Module: check_mk Branch: master Commit: bbec8d7b03da4f6d074aef862070b5b70b96bcf9 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bbec8d7b03da4f…
Author: Jukka Aro <ja(a)mathias-kettner.de> Date: Tue Mar 13 15:47:17 2018 +0100 Clang-format C++ code Do formatting for the first time uniformly for the previously excluded subdirectories agents/windows/sections, agents/windows/test and agents/windows/sections/test. --- agents/windows/build_version | 2 +- agents/windows/sections/SectionDF.cc | 3 ++- agents/windows/sections/SectionDF.h | 3 ++- agents/windows/sections/SectionEventlog.cc | 6 ++++++ agents/windows/sections/SectionFileinfo.cc | 3 ++- agents/windows/sections/SectionFileinfo.h | 3 ++- agents/windows/sections/SectionGroup.cc | 7 ++++--- agents/windows/sections/SectionGroup.h | 6 ++++-- agents/windows/sections/SectionLogwatch.cc | 3 ++- agents/windows/sections/SectionLogwatch.h | 3 ++- agents/windows/sections/SectionMRPE.cc | 3 ++- agents/windows/sections/SectionMRPE.h | 3 ++- agents/windows/sections/SectionMem.cc | 3 ++- agents/windows/sections/SectionMem.h | 3 ++- agents/windows/sections/SectionOHM.cc | 3 ++- agents/windows/sections/SectionOHM.h | 3 ++- agents/windows/sections/SectionPS.cc | 3 ++- agents/windows/sections/SectionPS.h | 3 ++- agents/windows/sections/SectionPerfcounter.cc | 3 ++- agents/windows/sections/SectionPerfcounter.h | 3 ++- agents/windows/sections/SectionPluginGroup.cc | 8 ++++---- agents/windows/sections/SectionPluginGroup.h | 3 ++- agents/windows/sections/SectionServices.cc | 3 ++- agents/windows/sections/SectionServices.h | 3 ++- agents/windows/sections/SectionSkype.cc | 5 +++-- agents/windows/sections/SectionSkype.h | 3 ++- agents/windows/sections/SectionSpool.cc | 3 ++- agents/windows/sections/SectionSpool.h | 3 ++- agents/windows/sections/SectionSystemtime.cc | 3 ++- agents/windows/sections/SectionSystemtime.h | 3 ++- agents/windows/sections/SectionUptime.cc | 3 ++- agents/windows/sections/SectionUptime.h | 3 ++- agents/windows/sections/SectionWMI.cc | 3 ++- agents/windows/sections/SectionWMI.h | 3 ++- agents/windows/sections/SectionWinperf.cc | 3 ++- agents/windows/sections/SectionWinperf.h | 3 ++- agents/windows/test/ConfigurationTest.cc | 3 ++- agents/windows/test/MockEnvironment.h | 2 +- agents/windows/test/RotatingFileHandlerTest.cc | 2 +- agents/windows/test/WritableFileTest.cc | 10 +++++----- 40 files changed, 91 insertions(+), 50 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=bbec8d7b03…
6 years, 6 months
1
0
0
0
Win-agent: const correctness fixes
by Jukka Aro
Module: check_mk Branch: master Commit: 2128a8ec00fb469ac485866c4b82f6f63c283e17 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2128a8ec00fb46…
Author: Jukka Aro <ja(a)mathias-kettner.de> Date: Tue Mar 13 14:41:37 2018 +0100 Win-agent: const correctness fixes Make _show_header and _nested members immutable. They are known at (Section) object initialization time, so there is no real need to change them afterwards. --- agents/windows/Section.cc | 10 +++------- agents/windows/Section.h | 9 +++------ agents/windows/SectionManager.cc | 26 ++++++++++++-------------- agents/windows/build_version | 2 +- agents/windows/sections/SectionGroup.cc | 15 +++++---------- agents/windows/sections/SectionGroup.h | 6 +++--- agents/windows/sections/SectionPluginGroup.cc | 6 +----- agents/windows/sections/SectionSkype.cc | 3 +-- agents/windows/sections/SectionSpool.cc | 4 +--- 9 files changed, 30 insertions(+), 51 deletions(-) diff --git a/agents/windows/Section.cc b/agents/windows/Section.cc index d11ca5a..7583eef 100644 --- a/agents/windows/Section.cc +++ b/agents/windows/Section.cc @@ -52,17 +52,13 @@ double current_time(const WinApiAdaptor &winapi) { Section::Section(const std::string &outputName, const std::string &configName, const Environment &env, Logger *logger, - const WinApiAdaptor &winapi) + const WinApiAdaptor &winapi, bool show_header /* = true */) : _outputName(outputName) , _configName(configName) , _env(env) , _logger(logger) - , _winapi(winapi) {} - -Section *Section::withHiddenHeader(bool hidden) { - _show_header = !hidden; - return this; -} + , _winapi(winapi) + , _show_header(show_header) {} Section *Section::withRealtimeSupport() { _realtime_support = true; diff --git a/agents/windows/Section.h b/agents/windows/Section.h index 57ccf94..53ac129 100644 --- a/agents/windows/Section.h +++ b/agents/windows/Section.h @@ -47,12 +47,10 @@ double current_time(const WinApiAdaptor &winapi); } // namespace section_helpers class Section { - friend class SectionGroup; - public: Section(const std::string &outputName, const std::string &configName, - const Environment &env, Logger *logger, - const WinApiAdaptor &winapi); + const Environment &env, Logger *logger, const WinApiAdaptor &winapi, + bool show_header = true); virtual ~Section() = default; @@ -61,7 +59,6 @@ public: return this; } - Section *withHiddenHeader(bool hidden = true); Section *withRealtimeSupport(); virtual void postprocessConfig() {} @@ -101,7 +98,7 @@ protected: const WinApiAdaptor &_winapi; private: - bool _show_header{true}; + const bool _show_header; char _separator{' '}; bool _realtime_support{false}; }; diff --git a/agents/windows/SectionManager.cc b/agents/windows/SectionManager.cc index 6ab5d47..c4620c8 100644 --- a/agents/windows/SectionManager.cc +++ b/agents/windows/SectionManager.cc @@ -154,19 +154,18 @@ void SectionManager::loadStaticSections(Configuration &config, ->withObject(L"Win32_PerfRawData_NETFramework_NETCLRMemory") ->withToggleIfMissing()); - addSection( - (new SectionGroup("wmi_cpuload", "wmi_cpuload", _env, _logger, _winapi)) - ->withToggleIfMissing() - ->withNestedSubtables() - ->withSubSection( - (new SectionWMI("system_perf", "system_perf", _env, _logger, - _winapi)) - ->withObject(L"Win32_PerfRawData_PerfOS_System")) - ->withSubSection( - (new SectionWMI("computer_system", "computer_system", _env, - _logger, _winapi)) - ->withObject(L"Win32_ComputerSystem")) - ->withSeparator(',')); + addSection((new SectionGroup("wmi_cpuload", "wmi_cpuload", _env, _logger, + _winapi, true, true)) + ->withToggleIfMissing() + ->withSubSection( + (new SectionWMI("system_perf", "system_perf", _env, + _logger, _winapi)) + ->withObject(L"Win32_PerfRawData_PerfOS_System")) + ->withSubSection( + (new SectionWMI("computer_system", "computer_system", + _env, _logger, _winapi)) + ->withObject(L"Win32_ComputerSystem")) + ->withSeparator(',')); addSection( (new SectionGroup("msexch", "msexch", _env, _logger, _winapi)) @@ -207,7 +206,6 @@ void SectionManager::loadStaticSections(Configuration &config, _winapi)) ->withObject( L"Win32_PerfRawData_MSExchangeRpcClientAccess_MSExchangeRpcClientAccess")) - ->withHiddenHeader() ->withSeparator(',')); addSection(new SectionSkype(_env, _logger, _winapi)); diff --git a/agents/windows/build_version b/agents/windows/build_version index 98ee87f..01e0503 100644 --- a/agents/windows/build_version +++ b/agents/windows/build_version @@ -1 +1 @@ -3166 +3168 diff --git a/agents/windows/sections/SectionGroup.cc b/agents/windows/sections/SectionGroup.cc index 1103dde..db55929 100644 --- a/agents/windows/sections/SectionGroup.cc +++ b/agents/windows/sections/SectionGroup.cc @@ -28,10 +28,11 @@ SectionGroup::SectionGroup(const std::string &outputName, const std::string &configName, const Environment &env, Logger *logger, - const WinApiAdaptor &winapi) - : Section(outputName, configName, env, logger, winapi) { - withHiddenHeader(); -} + const WinApiAdaptor &winapi, + bool nested /* = false */, + bool show_header /* = false */) + : Section(outputName, configName, env, logger, winapi, show_header) + , _nested(nested) {} SectionGroup *SectionGroup::withSubSection(Section *section) { _subsections.push_back(std::unique_ptr<Section>(section)); @@ -48,12 +49,6 @@ SectionGroup *SectionGroup::withToggleIfMissing() { return this; } -SectionGroup *SectionGroup::withNestedSubtables() { - withHiddenHeader(false); - _nested = true; - return this; -} - bool SectionGroup::produceOutputInner(std::ostream &out, const std::optional<std::string> &remoteIP) { Debug(_logger) << "SectionGroup::produceOutputInner"; time_t now = time(nullptr); diff --git a/agents/windows/sections/SectionGroup.h b/agents/windows/sections/SectionGroup.h index 42350f0..08c0b1b 100644 --- a/agents/windows/sections/SectionGroup.h +++ b/agents/windows/sections/SectionGroup.h @@ -43,8 +43,8 @@ class SectionGroup : public Section { public: SectionGroup(const std::string &outputName, const std::string &configName, const Environment &env, Logger *logger, - const WinApiAdaptor &winapi); - SectionGroup *withNestedSubtables(); + const WinApiAdaptor &winapi, bool nested = false, bool show_header = false); + /** * add a section that will be printed as part of this group **/ @@ -67,7 +67,7 @@ private: std::vector<std::unique_ptr<Section>> _dependent_subsections; bool _toggle_if_missing{false}; bool _fail_if_missing{false}; - bool _nested{false}; + const bool _nested; time_t _disabled_until{0}; }; diff --git a/agents/windows/sections/SectionPluginGroup.cc b/agents/windows/sections/SectionPluginGroup.cc index b3a2cd9..d58d838 100644 --- a/agents/windows/sections/SectionPluginGroup.cc +++ b/agents/windows/sections/SectionPluginGroup.cc @@ -376,7 +376,7 @@ SectionPluginGroup::SectionPluginGroup( script_statistics_t &script_statistics, Logger *logger, const WinApiAdaptor &winapi, const std::string &user) : Section(typeToSection(type), typeToSection(type), config.getEnvironment(), - logger, winapi) + logger, winapi, type != PLUGIN) // plugin -> no collective header , _path(path) , _type(type) , _user(user) @@ -390,10 +390,6 @@ SectionPluginGroup::SectionPluginGroup( , _retry_count(config, typeToSection(type), "retry_count", _winapi) , _execution_mode(config, typeToSection(type), "execution", _winapi) , _script_statistics(script_statistics) { - if (type == PLUGIN) { - // plugins don't have a "collective" header - withHiddenHeader(); - } } SectionPluginGroup::~SectionPluginGroup() { _containers.clear(); } diff --git a/agents/windows/sections/SectionSkype.cc b/agents/windows/sections/SectionSkype.cc index b986f56..b6bdcf7 100644 --- a/agents/windows/sections/SectionSkype.cc +++ b/agents/windows/sections/SectionSkype.cc @@ -30,10 +30,9 @@ SectionSkype::SectionSkype(const Environment &env, Logger *logger, const WinApiAdaptor &winapi) - : SectionGroup("skype", "skype", env, logger, winapi) + : SectionGroup("skype", "skype", env, logger, winapi, true, true) , _nameNumberMap(_logger, _winapi) { withToggleIfMissing(); - withNestedSubtables(); withSeparator(','); for (const std::string &counterName : diff --git a/agents/windows/sections/SectionSpool.cc b/agents/windows/sections/SectionSpool.cc index 8a74e47..f4b1fdb 100644 --- a/agents/windows/sections/SectionSpool.cc +++ b/agents/windows/sections/SectionSpool.cc @@ -34,9 +34,7 @@ namespace fs = std::experimental::filesystem; SectionSpool::SectionSpool(const Environment &env, Logger *logger, const WinApiAdaptor &winapi) - : Section("spool", "spool", env, logger, winapi) { - withHiddenHeader(); -} + : Section("spool", "spool", env, logger, winapi, false) {} bool SectionSpool::produceOutputInner(std::ostream &out, const std::optional<std::string> &) { Debug(_logger) << "SectionSpool::produceOutputInner";
6 years, 6 months
1
0
0
0
← Newer
1
...
16
17
18
19
20
21
22
...
33
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
Results per page:
10
25
50
100
200