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
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 2018
----- 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
287 discussions
Start a n
N
ew thread
Win-agent: rename ISectionHeader to SectionHeaderBase
by Jukka Aro
Module: check_mk Branch: master Commit: 352cd23abee1c29ade92a34e46f3238e43034165 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=352cd23abee1c2…
Author: Jukka Aro <ja(a)mathias-kettner.de> Date: Fri Apr 6 11:20:26 2018 +0200 Win-agent: rename ISectionHeader to SectionHeaderBase Move away from Microsoft-style naming in an abstract base class not defined by Microsoft. --- agents/windows/build_version | 2 +- agents/windows/sections/Section.cc | 2 +- agents/windows/sections/Section.h | 6 +++--- agents/windows/sections/SectionGroup.cc | 6 +++--- agents/windows/sections/SectionHeader.h | 14 +++++++------- agents/windows/sections/SectionPluginGroup.cc | 3 ++- agents/windows/sections/SectionWMI.cc | 6 +++--- 7 files changed, 20 insertions(+), 19 deletions(-) diff --git a/agents/windows/build_version b/agents/windows/build_version index b4732da..28206c2 100644 --- a/agents/windows/build_version +++ b/agents/windows/build_version @@ -1 +1 @@ -3220 +3222 diff --git a/agents/windows/sections/Section.cc b/agents/windows/sections/Section.cc index 1509c3a..a1857cc 100644 --- a/agents/windows/sections/Section.cc +++ b/agents/windows/sections/Section.cc @@ -30,7 +30,7 @@ Section::Section(const std::string &configName, const Environment &env, Logger *logger, const WinApiInterface &winapi, - std::unique_ptr<ISectionHeader> header) + std::unique_ptr<SectionHeaderBase> header) : _configName(configName) , _env(env) , _logger(logger) diff --git a/agents/windows/sections/Section.h b/agents/windows/sections/Section.h index 2b7b85c..7f9975d 100644 --- a/agents/windows/sections/Section.h +++ b/agents/windows/sections/Section.h @@ -37,7 +37,7 @@ class Environment; class Logger; -class ISectionHeader; +class SectionHeaderBase; namespace section_helpers { @@ -55,7 +55,7 @@ class Section { public: Section(const std::string &configName, const Environment &env, Logger *logger, const WinApiInterface &winapi, - std::unique_ptr<ISectionHeader> header); + std::unique_ptr<SectionHeaderBase> header); virtual ~Section(); @@ -87,7 +87,7 @@ private: bool generateOutput(std::string &buffer, const std::optional<std::string> &remoteIP); - std::unique_ptr<ISectionHeader> _header; + std::unique_ptr<SectionHeaderBase> _header; }; #endif // Section_h diff --git a/agents/windows/sections/SectionGroup.cc b/agents/windows/sections/SectionGroup.cc index 65dfc75..42712b9 100644 --- a/agents/windows/sections/SectionGroup.cc +++ b/agents/windows/sections/SectionGroup.cc @@ -28,9 +28,9 @@ namespace { -std::unique_ptr<ISectionHeader> makeHeader(bool show_header, - const std::string &outputName, - Logger *logger) { +std::unique_ptr<SectionHeaderBase> makeHeader(bool show_header, + const std::string &outputName, + Logger *logger) { if (show_header) return std::make_unique<SectionHeader<',', SectionBrackets>>(outputName, logger); diff --git a/agents/windows/sections/SectionHeader.h b/agents/windows/sections/SectionHeader.h index 9037258..3eeccb6 100644 --- a/agents/windows/sections/SectionHeader.h +++ b/agents/windows/sections/SectionHeader.h @@ -59,18 +59,18 @@ struct SubSectionBrackets { static constexpr auto right = "]"; }; -class ISectionHeader { +class SectionHeaderBase { public: - ISectionHeader() = default; - ISectionHeader(const ISectionHeader &) = delete; - virtual ~ISectionHeader() = default; - ISectionHeader &operator=(const ISectionHeader &) = delete; + SectionHeaderBase() = default; + SectionHeaderBase(const SectionHeaderBase &) = delete; + virtual ~SectionHeaderBase() = default; + SectionHeaderBase &operator=(const SectionHeaderBase &) = delete; virtual std::ostream &output(std::ostream &os) const = 0; }; template <unsigned char SepChar, class Brackets> -class SectionHeader : public ISectionHeader { +class SectionHeader : public SectionHeaderBase { public: SectionHeader(const std::string &name, Logger *logger) : _name(name), _logger(logger) {} @@ -98,7 +98,7 @@ public: }; inline std::ostream &operator<<(std::ostream &os, - const ISectionHeader &header) { + const SectionHeaderBase &header) { return header.output(os); } diff --git a/agents/windows/sections/SectionPluginGroup.cc b/agents/windows/sections/SectionPluginGroup.cc index 3b75e7c..b51a850 100644 --- a/agents/windows/sections/SectionPluginGroup.cc +++ b/agents/windows/sections/SectionPluginGroup.cc @@ -202,7 +202,8 @@ ScriptWorkerThread(LPVOID lpParam) { return 0; } -std::unique_ptr<ISectionHeader> makeHeader(script_type type, Logger *logger) { +std::unique_ptr<SectionHeaderBase> makeHeader(script_type type, + Logger *logger) { if (type != script_type::PLUGIN) return std::make_unique<DefaultHeader>(typeToSection(type), logger); else // plugin -> no collective header diff --git a/agents/windows/sections/SectionWMI.cc b/agents/windows/sections/SectionWMI.cc index 2c66a12..56c8b9a 100644 --- a/agents/windows/sections/SectionWMI.cc +++ b/agents/windows/sections/SectionWMI.cc @@ -37,9 +37,9 @@ namespace { -std::unique_ptr<ISectionHeader> makeHeader(bool subSection, - const std::string &outputName, - Logger *logger) { +std::unique_ptr<SectionHeaderBase> makeHeader(bool subSection, + const std::string &outputName, + Logger *logger) { if (subSection) return std::make_unique<SubSectionHeader>(outputName, logger); else
6 years, 5 months
1
0
0
0
Rename WinAPI wrapper base class to WinApiInterface
by Jukka Aro
Module: check_mk Branch: master Commit: 6db804665c4dd35ff063cc9d2cf7c9e9978706ee URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6db804665c4dd3…
Author: Jukka Aro <ja(a)mathias-kettner.de> Date: Fri Apr 6 10:54:34 2018 +0200 Rename WinAPI wrapper base class to WinApiInterface The naming WinApiAdaptor misleadingly reminded of Adaptor Pattern, which this is implementation is (at least not yet) following. The current implementation rather reminds of the Facade Pattern. This may change in the future, though, as there would be a need for adapting the data types passed through the wrapper class in order to cut direct dependencies to Microsoft-specific data types. Change the naming of the abstract base wrapper class to describe its role as an "interface" with exclusively pure virtual member functions. --- agents/windows/Configurable.h | 15 ++++---- agents/windows/CrashHandler.cc | 6 ++-- agents/windows/CrashHandler.h | 6 ++-- agents/windows/Crypto.cc | 8 ++--- agents/windows/Crypto.h | 12 +++---- agents/windows/Environment.cc | 4 +-- agents/windows/Environment.h | 6 ++-- agents/windows/EventLog.cc | 6 ++-- agents/windows/EventLog.h | 12 +++---- agents/windows/EventLogVista.cc | 16 ++++----- agents/windows/EventLogVista.h | 12 +++---- agents/windows/ExternalCmd.cc | 10 +++--- agents/windows/ExternalCmd.h | 6 ++-- agents/windows/IEventLog.cc | 2 +- agents/windows/IEventLog.h | 4 +-- agents/windows/ListenSocket.cc | 4 +-- agents/windows/ListenSocket.h | 9 ++--- agents/windows/OHMMonitor.cc | 6 ++-- agents/windows/OHMMonitor.h | 8 ++--- agents/windows/OutputProxy.cc | 6 ++-- agents/windows/OutputProxy.h | 9 ++--- agents/windows/PerfCounter.cc | 4 +-- agents/windows/PerfCounter.h | 12 +++---- agents/windows/PerfCounterCommon.cc | 6 ++-- agents/windows/PerfCounterCommon.h | 21 ++++++------ agents/windows/SectionManager.cc | 4 +-- agents/windows/SectionManager.h | 8 ++--- agents/windows/Thread.cc | 2 +- agents/windows/Thread.h | 6 ++-- agents/windows/WinApi.h | 4 +-- .../windows/{WinApiAdaptor.h => WinApiInterface.h} | 16 ++++----- agents/windows/WritableFile.cc | 6 ++-- agents/windows/WritableFile.h | 8 ++--- agents/windows/build_version | 2 +- agents/windows/dynamic_func.h | 4 +-- agents/windows/sections/Section.cc | 2 +- agents/windows/sections/Section.h | 6 ++-- agents/windows/sections/SectionCheckMK.cc | 2 +- agents/windows/sections/SectionCheckMK.h | 2 +- agents/windows/sections/SectionDF.cc | 6 ++-- agents/windows/sections/SectionDF.h | 2 +- agents/windows/sections/SectionEventlog.cc | 4 +-- agents/windows/sections/SectionEventlog.h | 6 ++-- agents/windows/sections/SectionFileinfo.cc | 10 +++--- agents/windows/sections/SectionFileinfo.h | 2 +- agents/windows/sections/SectionGroup.cc | 2 +- agents/windows/sections/SectionGroup.h | 2 +- agents/windows/sections/SectionLogwatch.cc | 4 +-- agents/windows/sections/SectionLogwatch.h | 8 ++--- agents/windows/sections/SectionMRPE.cc | 5 +-- agents/windows/sections/SectionMRPE.h | 4 +-- agents/windows/sections/SectionMem.cc | 2 +- agents/windows/sections/SectionMem.h | 2 +- agents/windows/sections/SectionOHM.cc | 2 +- agents/windows/sections/SectionOHM.h | 2 +- agents/windows/sections/SectionPS.cc | 2 +- agents/windows/sections/SectionPS.h | 2 +- agents/windows/sections/SectionPerfcounter.cc | 2 +- agents/windows/sections/SectionPerfcounter.h | 6 ++-- agents/windows/sections/SectionPluginGroup.cc | 8 ++--- agents/windows/sections/SectionPluginGroup.h | 13 +++---- agents/windows/sections/SectionServices.cc | 2 +- agents/windows/sections/SectionServices.h | 2 +- agents/windows/sections/SectionSkype.cc | 4 +-- agents/windows/sections/SectionSkype.h | 2 +- agents/windows/sections/SectionSpool.cc | 2 +- agents/windows/sections/SectionSpool.h | 2 +- agents/windows/sections/SectionSystemtime.cc | 2 +- agents/windows/sections/SectionSystemtime.h | 2 +- agents/windows/sections/SectionUptime.cc | 2 +- agents/windows/sections/SectionUptime.h | 2 +- agents/windows/sections/SectionWMI.cc | 2 +- agents/windows/sections/SectionWMI.h | 2 +- agents/windows/sections/SectionWinperf.cc | 2 +- agents/windows/sections/SectionWinperf.h | 2 +- agents/windows/stringutil.cc | 8 ++--- agents/windows/stringutil.h | 8 ++--- agents/windows/test/EventLogVistaTest.cc | 2 +- agents/windows/test/MockEnvironment.cc | 2 +- agents/windows/test/MockEnvironment.h | 4 +-- agents/windows/test/MockWinApi.h | 4 +-- agents/windows/types.cc | 12 +++---- agents/windows/types.h | 40 ++++++++++++---------- agents/windows/win_error.cc | 6 ++-- agents/windows/win_error.h | 6 ++-- agents/windows/wmiHelper.cc | 26 +++++++------- agents/windows/wmiHelper.h | 26 +++++++------- 87 files changed, 279 insertions(+), 273 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=6db804665c…
6 years, 5 months
1
0
0
0
Tiny simplification: Use instance property instead of argument.
by Sven Panne
Module: check_mk Branch: master Commit: e4052e974be9c3730683f73e6f3b7ea13bd6bddf URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e4052e974be9c3…
Author: Sven Panne <sp(a)mathias-kettner.de> Date: Fri Apr 6 10:37:16 2018 +0200 Tiny simplification: Use instance property instead of argument. Change-Id: Ifb16ba7cd7cd7e92d704cea3b822760cc2c9fceb --- cmk/ec/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmk/ec/main.py b/cmk/ec/main.py index 8a78f25..82864ba 100644 --- a/cmk/ec/main.py +++ b/cmk/ec/main.py @@ -3664,7 +3664,7 @@ class StatusServer(ECServerThread): elif query.method == "COMMAND": if not allow_commands: raise MKClientError("Sorry. Commands are disallowed via TCP") - self.handle_command_request(self._event_server, self.table_events, query.method_arg) + self.handle_command_request(self._event_server, query.method_arg) response = None else: @@ -3704,14 +3704,14 @@ class StatusServer(ECServerThread): client_socket.sendall(repr(response) + "\n") # All commands are already locked with lock_eventstatus - def handle_command_request(self, event_server, table_events, commandline): + def handle_command_request(self, event_server, commandline): self.logger.info("Executing command: %s" % commandline) parts = commandline.split(";") command = parts[0] replication_allow_command(command) arguments = parts[1:] if command == "DELETE": - self.handle_command_delete(table_events, arguments) + self.handle_command_delete(arguments) elif command == "RELOAD": self.handle_command_reload(self._event_server) elif command == "SHUTDOWN": @@ -3738,11 +3738,11 @@ class StatusServer(ECServerThread): else: raise MKClientError("Unknown command %s" % command) - def handle_command_delete(self, table_events, arguments): + def handle_command_delete(self, arguments): if len(arguments) != 2: raise MKClientError("Wrong number of arguments for DELETE") event_id, user = arguments - self._event_status.delete_event(self, table_events, int(event_id), user) + self._event_status.delete_event(self, self.table_events, int(event_id), user) def handle_command_update(self, arguments): event_id, user, acknowledged, comment, contact = arguments
6 years, 5 months
1
0
0
0
Finally nuked global variable g_status_server.
by Sven Panne
Module: check_mk Branch: master Commit: 0505b2cf5bac3e1e5e2510f542be933b341c0f0f URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0505b2cf5bac3e…
Author: Sven Panne <sp(a)mathias-kettner.de> Date: Fri Apr 6 10:28:51 2018 +0200 Finally nuked global variable g_status_server. Change-Id: I650231d6357399fbe478aec34ccd22f8769bee67 --- cmk/ec/main.py | 23 +++++++++++++---------- tests/integration/cmk/ec/test_mkeventd_status.py | 18 +++++++++++------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/cmk/ec/main.py b/cmk/ec/main.py index d75271a..8a78f25 100644 --- a/cmk/ec/main.py +++ b/cmk/ec/main.py @@ -269,9 +269,10 @@ class ECLock(object): class ECServerThread(threading.Thread): - def __init__(self, name, settings, profiling_enabled, profile_file): + def __init__(self, name, settings, table_events, profiling_enabled, profile_file): super(ECServerThread, self).__init__(name=name) self.settings = settings + self._table_events = table_events self._profiling_enabled = profiling_enabled self._profile_file = profile_file self._terminate_event = threading.Event() @@ -284,7 +285,7 @@ class ECServerThread(threading.Thread): try: with cmk.profile.Profile(enabled=self._profiling_enabled, profile_file=str(self._profile_file)): - self.serve(g_status_server.table_events) + self.serve(self._table_events) except Exception: self.logger.exception("Exception in %s server" % self.name) if self._settings.options.debug: @@ -1254,9 +1255,10 @@ class EventServer(ECServerThread): month_names = {"Jan": 1, "Feb": 2, "Mar": 3, "Apr": 4, "May": 5, "Jun": 6, "Jul": 7, "Aug": 8, "Sep": 9, "Oct": 10, "Nov": 11, "Dec": 12} - def __init__(self, settings, perfcounters, event_status): + def __init__(self, settings, perfcounters, event_status, table_events): super(EventServer, self).__init__(name="EventServer", settings=settings, + table_events=table_events, profiling_enabled=settings.options.profile_event, profile_file=settings.paths.event_server_profile.value) self._syslog = None @@ -3510,16 +3512,17 @@ class StatusTableStatus(StatusTable): # '----------------------------------------------------------------------' class StatusServer(ECServerThread): - def __init__(self, settings, perfcounters, event_status, event_server): + def __init__(self, settings, perfcounters, event_status, event_server, table_events): super(StatusServer, self).__init__(name="StatusServer", settings=settings, + table_events=table_events, profiling_enabled=settings.options.profile_status, profile_file=settings.paths.status_server_profile.value) self._socket = None self._tcp_socket = None self._reopen_sockets = False - self.table_events = StatusTableEvents(event_status) + self.table_events = table_events self.table_history = StatusTableHistory(settings, self.table_events) self.table_rules = StatusTableRules(event_status) self.table_status = StatusTableStatus(event_server) @@ -5053,15 +5056,15 @@ def main(): settings.paths.status_file.value.parent.mkdir(parents=True, exist_ok=True) # First do all things that might fail, before daemonizing - global g_status_server perfcounters = Perfcounters() event_status = EventStatus(settings, perfcounters) - event_server = EventServer(settings, perfcounters, event_status) - g_status_server = StatusServer(settings, perfcounters, event_status, event_server) + table_events = StatusTableEvents(event_status) + event_server = EventServer(settings, perfcounters, event_status, table_events) + status_server = StatusServer(settings, perfcounters, event_status, event_server, table_events) event_status.load_status(event_server) - initialize_snmptrap_handling(settings, event_server, g_status_server.table_events) + initialize_snmptrap_handling(settings, event_server, table_events) event_server.compile_rules(g_config["rules"], g_config["rule_packs"]) @@ -5079,7 +5082,7 @@ def main(): signal.signal(signal.SIGTERM, signal_handler) # Now let's go... - run_eventd(settings, perfcounters, event_status, event_server, g_status_server) + run_eventd(settings, perfcounters, event_status, event_server, status_server) # We reach this point, if the server has been killed by # a signal or hitting Ctrl-C (in foreground mode) diff --git a/tests/integration/cmk/ec/test_mkeventd_status.py b/tests/integration/cmk/ec/test_mkeventd_status.py index bca73cd..d140a79 100644 --- a/tests/integration/cmk/ec/test_mkeventd_status.py +++ b/tests/integration/cmk/ec/test_mkeventd_status.py @@ -62,14 +62,18 @@ def event_status(settings, perfcounters): @pytest.fixture(scope="function") -def event_server(settings, config, perfcounters, event_status): - return cmk.ec.main.EventServer(settings, perfcounters, event_status) +def table_events(event_status): + return cmk.ec.main.StatusTableEvents(event_status) @pytest.fixture(scope="function") -def status_server(settings, config, perfcounters, event_status, event_server): - cmk.ec.main.g_status_server = cmk.ec.main.StatusServer(settings, perfcounters, event_status, event_server) - return cmk.ec.main.g_status_server +def event_server(settings, config, perfcounters, event_status, table_events): + return cmk.ec.main.EventServer(settings, perfcounters, event_status, table_events) + + +(a)pytest.fixture(scope="function") +def status_server(settings, config, perfcounters, event_status, event_server, table_events): + return cmk.ec.main.StatusServer(settings, perfcounters, event_status, event_server, table_events) def test_handle_client(status_server): @@ -82,9 +86,9 @@ def test_handle_client(status_server): assert "event_id" in response[0] -def test_mkevent_check_query_perf(config, event_status, status_server): +def test_mkevent_check_query_perf(config, event_status, status_server, table_events): for num in range(10000): - event_status.new_event(status_server.table_events, CMKEventConsole.new_event({ + event_status.new_event(table_events, CMKEventConsole.new_event({ "host": "heute-%d" % num, "text": "%s %s BLA BLUB DINGELING ABASD AD R#@A AR@AR A@ RA@R A@RARAR ARKNLA@RKA@LRKNA@KRLNA@RLKNA@äRLKA@RNKAL@R" \ " j:O#A@J$ KLA@J $L:A@J :AMW: RAMR@: RMA@:LRMA@ L:RMA@ :AL@R MA:L@RM A@:LRMA@ :RLMA@ R:LA@RMM@RL:MA@R: AM@" % \
6 years, 5 months
1
0
0
0
Decoupling: Only pass those parts of StatusServer around which are actually needed.
by Sven Panne
Module: check_mk Branch: master Commit: 4657aa293fa8e02aea57ca945e190102a457f9ed URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4657aa293fa8e0…
Author: Sven Panne <sp(a)mathias-kettner.de> Date: Fri Apr 6 09:03:18 2018 +0200 Decoupling: Only pass those parts of StatusServer around which are actually needed. Change-Id: I298c3d9ea55640b4971e132c3b017e2ba2242071 --- cmk/ec/main.py | 242 +++++++++++------------ tests/integration/cmk/ec/test_mkeventd_status.py | 2 +- 2 files changed, 122 insertions(+), 122 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=4657aa293f…
6 years, 5 months
1
0
0
0
Synched test with latest EC changes.
by Sven Panne
Module: check_mk Branch: master Commit: 2ff4ef34aa1399e6f33e9d04dd054e647868a581 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2ff4ef34aa1399…
Author: Sven Panne <sp(a)mathias-kettner.de> Date: Thu Apr 5 15:40:24 2018 +0200 Synched test with latest EC changes. Change-Id: I1ed226fa8f9e72da7d8e42336606034742840bfd --- tests/integration/cmk/ec/test_mkeventd_status.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/cmk/ec/test_mkeventd_status.py b/tests/integration/cmk/ec/test_mkeventd_status.py index 424137d..7b1ef52 100644 --- a/tests/integration/cmk/ec/test_mkeventd_status.py +++ b/tests/integration/cmk/ec/test_mkeventd_status.py @@ -72,17 +72,17 @@ def status_server(settings, config, perfcounters, event_status, event_server): return cmk.ec.main.g_status_server -def test_handle_client(event_status, event_server, status_server): +def test_handle_client(status_server): s = FakeStatusSocket("GET events") - status_server.handle_client(event_server, s, True, "127.0.0.1") + status_server.handle_client(s, True, "127.0.0.1") response = s.get_response() assert len(response) == 1 assert "event_id" in response[0] -def test_mkevent_check_query_perf(config, perfcounters, event_status, status_server): +def test_mkevent_check_query_perf(config, event_status, status_server): for num in range(10000): event_status.new_event(status_server, CMKEventConsole.new_event({ "host": "heute-%d" % num, @@ -105,7 +105,7 @@ def test_mkevent_check_query_perf(config, perfcounters, event_status, status_ser #import cProfile, StringIO, pstats #pr = cProfile.Profile() #pr.enable() - status_server.handle_client(event_server, s, True, "127.0.0.1") + status_server.handle_client(s, True, "127.0.0.1") #pr.disable() #ps = pstats.Stats(pr, stream=StringIO.StringIO()) #ps.dump_stats("/tmp/test_mkevent_check_query_perf.profile")
6 years, 5 months
1
0
0
0
Finally nuked global variable g_event_server.
by Sven Panne
Module: check_mk Branch: master Commit: 663f5bfea3bbb898df1ae21daa71eae2e3d4cb80 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=663f5bfea3bbb8…
Author: Sven Panne <sp(a)mathias-kettner.de> Date: Thu Apr 5 15:33:42 2018 +0200 Finally nuked global variable g_event_server. Change-Id: I9aa01b0894ccadde7985873d2760693d448a4988 --- cmk/ec/main.py | 18 +++++++++--------- tests/integration/cmk/ec/test_mkeventd_status.py | 3 +-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cmk/ec/main.py b/cmk/ec/main.py index 2365a9b..2db48c4 100644 --- a/cmk/ec/main.py +++ b/cmk/ec/main.py @@ -5053,17 +5053,17 @@ def main(): settings.paths.status_file.value.parent.mkdir(parents=True, exist_ok=True) # First do all things that might fail, before daemonizing - global g_status_server, g_event_server + global g_status_server perfcounters = Perfcounters() event_status = EventStatus(settings, perfcounters) - g_event_server = EventServer(settings, perfcounters, event_status) - g_status_server = StatusServer(settings, perfcounters, event_status, g_event_server) + event_server = EventServer(settings, perfcounters, event_status) + g_status_server = StatusServer(settings, perfcounters, event_status, event_server) - event_status.load_status(g_event_server) + event_status.load_status(event_server) - initialize_snmptrap_handling(settings, g_event_server, g_status_server) + initialize_snmptrap_handling(settings, event_server, g_status_server) - g_event_server.compile_rules(g_config["rules"], g_config["rule_packs"]) + event_server.compile_rules(g_config["rules"], g_config["rule_packs"]) if not settings.options.foreground: pid_path.parent.mkdir(parents=True, exist_ok=True) @@ -5079,7 +5079,7 @@ def main(): signal.signal(signal.SIGTERM, signal_handler) # Now let's go... - run_eventd(settings, perfcounters, event_status, g_event_server, g_status_server) + run_eventd(settings, perfcounters, event_status, event_server, g_status_server) # We reach this point, if the server has been killed by # a signal or hitting Ctrl-C (in foreground mode) @@ -5090,7 +5090,7 @@ def main(): # that processes (syslog, etc) will not hang when trying # to write into the pipe. logger.verbose("Cleaning up event pipe") - pipe = g_event_server.open_pipe() # Open it + pipe = event_server.open_pipe() # Open it settings.paths.event_pipe.value.unlink() # Remove pipe drain_pipe(pipe) # Drain any data os.close(pipe) # Close pipe @@ -5103,7 +5103,7 @@ def main(): settings.paths.event_socket.value.unlink() logger.verbose("Output hash stats") - g_event_server.output_hash_stats() + event_server.output_hash_stats() logger.verbose("Closing fds which might be still open") for fd in [settings.options.syslog_udp, diff --git a/tests/integration/cmk/ec/test_mkeventd_status.py b/tests/integration/cmk/ec/test_mkeventd_status.py index 5bee45f..424137d 100644 --- a/tests/integration/cmk/ec/test_mkeventd_status.py +++ b/tests/integration/cmk/ec/test_mkeventd_status.py @@ -63,8 +63,7 @@ def event_status(settings, perfcounters): @pytest.fixture(scope="function") def event_server(settings, config, perfcounters, event_status): - cmk.ec.main.g_event_server = cmk.ec.main.StatusServer(settings, perfcounters, event_status) - return cmk.ec.main.g_event_server + return cmk.ec.main.EventServer(settings, perfcounters, event_status) @pytest.fixture(scope="function")
6 years, 5 months
1
0
0
0
Various simplifications regarding access to status server.
by Sven Panne
Module: check_mk Branch: master Commit: 2fb0e4e62a9157721372152139d8e6844f48147c URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2fb0e4e62a9157…
Author: Sven Panne <sp(a)mathias-kettner.de> Date: Thu Apr 5 15:20:43 2018 +0200 Various simplifications regarding access to status server. Change-Id: Ib4fed71978e9ccb819a9e518a146f44cb96dbadf --- cmk/ec/main.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/cmk/ec/main.py b/cmk/ec/main.py index e0148c5..2365a9b 100644 --- a/cmk/ec/main.py +++ b/cmk/ec/main.py @@ -284,7 +284,7 @@ class ECServerThread(threading.Thread): try: with cmk.profile.Profile(enabled=self._profiling_enabled, profile_file=str(self._profile_file)): - self.serve(g_event_server, g_status_server) + self.serve(g_status_server) except Exception: self.logger.exception("Exception in %s server" % self.name) if self._settings.options.debug: @@ -299,7 +299,7 @@ class ECServerThread(threading.Thread): def terminate(self): self._terminate_event.set() - def serve(self, event_server, status_server): + def serve(self, status_server): raise NotImplementedError() @@ -1597,7 +1597,7 @@ class EventServer(ECServerThread): return event - def serve(self, event_server, status_server): + def serve(self, status_server): pipe_fragment = '' pipe = self.open_pipe() listen_list = [pipe] @@ -3525,6 +3525,7 @@ class StatusServer(ECServerThread): self.table_status = StatusTableStatus(event_server) self._perfcounters = perfcounters self._event_status = event_status + self._event_server = event_server self.open_unix_socket() self.open_tcp_socket() @@ -3591,7 +3592,7 @@ class StatusServer(ECServerThread): def reload_configuration(self): self._reopen_sockets = True - def serve(self, event_server, status_server): + def serve(self, status_server): while not self._shal_terminate(): try: client_socket = None @@ -3631,7 +3632,7 @@ class StatusServer(ECServerThread): else: allow_commands = True - self.handle_client(event_server, status_server, client_socket, allow_commands, + self.handle_client(client_socket, allow_commands, addr_info and addr_info[0] or "") duration = time.time() - before @@ -3646,8 +3647,8 @@ class StatusServer(ECServerThread): time.sleep(0.2) client_socket = None # close without danger of exception - def handle_client(self, event_server, status_server, client_socket, allow_commands, client_ip): - for query in Queries(status_server, client_socket): + def handle_client(self, client_socket, allow_commands, client_ip): + for query in Queries(self, client_socket): self.logger.verbose("Client livestatus query: %r" % query) with lock_eventstatus: @@ -3660,7 +3661,7 @@ class StatusServer(ECServerThread): elif query.method == "COMMAND": if not allow_commands: raise MKClientError("Sorry. Commands are disallowed via TCP") - self.handle_command_request(event_server, query.method_arg) + self.handle_command_request(self._event_server, query.method_arg) response = None else: @@ -3709,10 +3710,10 @@ class StatusServer(ECServerThread): if command == "DELETE": self.handle_command_delete(arguments) elif command == "RELOAD": - self.handle_command_reload(event_server) + self.handle_command_reload(self._event_server) elif command == "SHUTDOWN": self.logger.info("Going to shut down") - terminate(event_server, self) + terminate(self._event_server, self) elif command == "REOPENLOG": self.handle_command_reopenlog() elif command == "FLUSH": @@ -3728,7 +3729,7 @@ class StatusServer(ECServerThread): elif command == "CHANGESTATE": self.handle_command_changestate(arguments) elif command == "ACTION": - self.handle_command_action(event_server, arguments) + self.handle_command_action(self._event_server, arguments) elif command == "SWITCHMODE": self.handle_command_switchmode(arguments) else: @@ -3772,7 +3773,7 @@ class StatusServer(ECServerThread): log_event_history(self.settings, self, event, "CHANGESTATE", user) def handle_command_reload(self, event_server): - reload_configuration(self.settings, event_server, self) + reload_configuration(self.settings, self._event_server, self) def handle_command_reopenlog(self): self.logger.info("Closing this logfile") @@ -3810,7 +3811,7 @@ class StatusServer(ECServerThread): event = self._event_status.event(int(event_id)) if action_id == "@NOTIFY": - do_notify(event_server, event, user, is_cancelling=False) + do_notify(self._event_server, event, user, is_cancelling=False) else: with lock_configuration: if action_id not in g_config["action"]: @@ -5056,7 +5057,7 @@ def main(): perfcounters = Perfcounters() event_status = EventStatus(settings, perfcounters) g_event_server = EventServer(settings, perfcounters, event_status) - g_status_server = StatusServer(settings, perfcounters, event_status, event_server) + g_status_server = StatusServer(settings, perfcounters, event_status, g_event_server) event_status.load_status(g_event_server)
6 years, 5 months
1
0
0
0
Synched test with latest EC changes.
by Sven Panne
Module: check_mk Branch: master Commit: 7c6690c168f28aff9d1777f772ec86526c88ed5d URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7c6690c168f28a…
Author: Sven Panne <sp(a)mathias-kettner.de> Date: Thu Apr 5 14:20:29 2018 +0200 Synched test with latest EC changes. Change-Id: I83b713c83de09567a61b8d8fa84be25125ffebc3 --- tests/integration/cmk/ec/test_mkeventd_status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/cmk/ec/test_mkeventd_status.py b/tests/integration/cmk/ec/test_mkeventd_status.py index 07a06ac..5bee45f 100644 --- a/tests/integration/cmk/ec/test_mkeventd_status.py +++ b/tests/integration/cmk/ec/test_mkeventd_status.py @@ -85,7 +85,7 @@ def test_handle_client(event_status, event_server, status_server): def test_mkevent_check_query_perf(config, perfcounters, event_status, status_server): for num in range(10000): - event_status.new_event(CMKEventConsole.new_event({ + event_status.new_event(status_server, CMKEventConsole.new_event({ "host": "heute-%d" % num, "text": "%s %s BLA BLUB DINGELING ABASD AD R#@A AR@AR A@ RA@R A@RARAR ARKNLA@RKA@LRKNA@KRLNA@RLKNA@äRLKA@RNKAL@R" \ " j:O#A@J$ KLA@J $L:A@J :AMW: RAMR@: RMA@:LRMA@ L:RMA@ :AL@R MA:L@RM A@:LRMA@ :RLMA@ R:LA@RMM@RL:MA@R: AM@" % \
6 years, 5 months
1
0
0
0
Removed global variable g_status_server, part 6.
by Sven Panne
Module: check_mk Branch: master Commit: 6258f1b5ce83f475090d970bee2569a2fcf75375 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6258f1b5ce83f4…
Author: Sven Panne <sp(a)mathias-kettner.de> Date: Thu Apr 5 13:48:30 2018 +0200 Removed global variable g_status_server, part 6. Change-Id: I967cc262f06119c76cfa0737d58d7d0a4607e704 --- cmk/ec/main.py | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/cmk/ec/main.py b/cmk/ec/main.py index 347139f..55afb06 100644 --- a/cmk/ec/main.py +++ b/cmk/ec/main.py @@ -463,17 +463,17 @@ class MKClientError(Exception): # | Generic SNMP-Trap processing functions | # '----------------------------------------------------------------------' -def initialize_snmptrap_handling(settings, event_server): +def initialize_snmptrap_handling(settings, event_server, status_server): if settings.options.snmptrap_udp is None: return - initialize_snmptrap_engine(event_server) + initialize_snmptrap_engine(event_server, status_server) if snmptrap_translation_enabled(): event_server.load_mibs() -def initialize_snmptrap_engine(event_server): +def initialize_snmptrap_engine(event_server, status_server): global g_snmp_engine, g_snmp_receiver g_snmp_engine = snmp_engine.SnmpEngine() @@ -482,7 +482,11 @@ def initialize_snmptrap_engine(event_server): pduTypes = (snmp_v1.TrapPDU.tagSet, snmp_v2c.SNMPv2TrapPDU.tagSet) initialize_snmp_credentials() - g_snmp_receiver = ECNotificationReceiver(g_snmp_engine, event_server.handle_snmptrap) + def handle_snmptrap(snmp_engine, state_reference, context_engine_id, context_name, + var_binds, cb_ctx): + event_server.handle_snmptrap(status_server, snmp_engine, state_reference, + context_engine_id, context_name, var_binds, cb_ctx) + g_snmp_receiver = ECNotificationReceiver(g_snmp_engine, handle_snmptrap) def initialize_snmp_credentials(): @@ -1547,7 +1551,7 @@ class EventServer(ECServerThread): g_snmp_engine.setUserContext(sender_address=sender_address) g_snmp_engine.msgAndPduDsp.receiveMessage(g_snmp_engine, (), (), whole_msg) - def handle_snmptrap(self, snmp_engine, state_reference, context_engine_id, context_name, + def handle_snmptrap(self, status_server, snmp_engine, state_reference, context_engine_id, context_name, var_binds, cb_ctx): ipaddress = snmp_engine.getUserContext("sender_address")[0] @@ -1559,7 +1563,7 @@ class EventServer(ECServerThread): trap = self.snmptrap_convert_var_binds(var_binds) event = self.create_event_from_trap(trap, ipaddress) - self.process_event(g_status_server, event) + self.process_event(status_server, event) def log_snmptrap_details(self, context_engine_id, context_name, var_binds, ipaddress): if self.logger.is_verbose(): @@ -3104,8 +3108,9 @@ class EventServer(ECServerThread): # '----------------------------------------------------------------------' class Queries(object): - def __init__(self, sock): + def __init__(self, status_server, sock): super(Queries, self).__init__() + self._status_server = status_server self._socket = sock self._buffer = "" @@ -3129,7 +3134,7 @@ class Queries(object): request_lines = request.decode("utf-8").splitlines() cls = Query.get_query_class(request_lines) - return cls(request_lines) + return cls(self._status_server, request_lines) class Query(object): @@ -3149,18 +3154,20 @@ class Query(object): raise MKClientError("Invalid method %s (allowed are %s) " % (method, ", ".join(cls._allowed_methods))) + # TODO: This is pure maintenance horror! Never ever calculate the name + # of a class in user code... return globals()["Query%s" % method] - def __init__(self, raw_query): + def __init__(self, status_server, raw_query): super(Query, self).__init__() self.logger = logger self.output_format = "python" self._raw_query = raw_query - self._from_raw_query() + self._from_raw_query(status_server) - def _from_raw_query(self): + def _from_raw_query(self, status_server): self._parse_method_and_args() def _parse_method_and_args(self): @@ -3177,9 +3184,9 @@ class Query(object): class QueryGET(Query): _allowed_tables = set(["events", "history", "rules", "status"]) - def _from_raw_query(self): - super(QueryGET, self)._from_raw_query() - self._parse_table(g_status_server) + def _from_raw_query(self, status_server): + super(QueryGET, self)._from_raw_query(status_server) + self._parse_table(status_server) self._parse_header_lines() def _parse_table(self, status_server): @@ -3620,7 +3627,7 @@ class StatusServer(ECServerThread): else: allow_commands = True - self.handle_client(event_server, client_socket, allow_commands, + self.handle_client(event_server, status_server, client_socket, allow_commands, addr_info and addr_info[0] or "") duration = time.time() - before @@ -3635,8 +3642,8 @@ class StatusServer(ECServerThread): time.sleep(0.2) client_socket = None # close without danger of exception - def handle_client(self, event_server, client_socket, allow_commands, client_ip): - for query in Queries(client_socket): + def handle_client(self, event_server, status_server, client_socket, allow_commands, client_ip): + for query in Queries(status_server, client_socket): self.logger.verbose("Client livestatus query: %r" % query) with lock_eventstatus: @@ -4976,7 +4983,7 @@ def load_configuration(settings): def reload_configuration(settings, event_server, status_server): with lock_configuration: load_configuration(settings) - initialize_snmptrap_handling(settings, event_server) + initialize_snmptrap_handling(settings, event_server, status_server) event_server.reload_configuration() status_server.reload_configuration() @@ -5049,7 +5056,7 @@ def main(): event_status.load_status(g_event_server) - initialize_snmptrap_handling(settings, g_event_server) + initialize_snmptrap_handling(settings, g_event_server, g_status_server) g_event_server.compile_rules(g_config["rules"], g_config["rule_packs"])
6 years, 5 months
1
0
0
0
← Newer
1
...
22
23
24
25
26
27
28
29
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
Results per page:
10
25
50
100
200