Module: check_mk
Branch: master
Commit: db66714eeef0e51f45f25715df56a0f95185e1c3
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=db66714eeef0e5…
Author: Sergey Kipnis <sk(a)mathias-kettner.de>
Date: Tue Dec 4 15:01:27 2018 +0100
[CMK-1382] - prevent agent crash when the error occurs during reading eventlog
6864 FIX Windows Agent crash during access to Event Log
Sometimes Windows Agent may crash when accessing Windows Event Log
because the size of the Log is too big or the Log itself is broken.
Now Windows Agent should skip such logs.
Change-Id: Ie513d5bb409b93bf2155a3d77481de0ec4cb02f1
---
.werks/6864 | 12 ++++++++++++
agents/windows/EventLog.cc | 23 +++++++++++++++++++----
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/.werks/6864 b/.werks/6864
new file mode 100644
index 0000000..08ce3ef
--- /dev/null
+++ b/.werks/6864
@@ -0,0 +1,12 @@
+Title: Windows Agent crash during access to Event Log
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1543932376
+Class: fix
+
+Sometimes Windows Agent may crash when accessing Windows Event Log
+because the size of the Log is too big or the Log itself is broken.
+Now Windows Agent should skip such logs.
diff --git a/agents/windows/EventLog.cc b/agents/windows/EventLog.cc
index 4726833..23d7ce8 100644
--- a/agents/windows/EventLog.cc
+++ b/agents/windows/EventLog.cc
@@ -175,8 +175,9 @@ wstring MessageResolver::resolve(DWORD eventID, LPCWSTR source,
result += parameters[i];
}
}
- std::replace_if(result.begin(), result.end(),
- [](wchar_t ch) { return ch == '\n' || ch == '\r'; }, ' ');
+ std::replace_if(
+ result.begin(), result.end(),
+ [](wchar_t ch) { return ch == '\n' || ch == '\r'; }, ' ');
return result;
}
@@ -307,8 +308,22 @@ std::unique_ptr<EventLogRecordBase> EventLog::read() {
if (result == nullptr) {
// no fitting record in our buffer, get the next couple of
// records
- if (!fillBuffer()) {
- // no more events to read, break out of the loop
+ try {
+ if (!fillBuffer()) {
+ // no more events to read, break out of the loop
+ break;
+ }
+ } catch (const std::exception &e) {
+ // win_exception is coming here
+ // generated exception in fillBuffer must be processed in any
+ // case usually we have something like FILE_TOO_LARGE(223)
+ // during reading Event Log and fpor some reason we thorw
+ // exception. Bad? Bad. In Fact, we have SERIOUS problem with
+ // monitored host. Our Log was informed. Probably we need some
+ // additional checks pointing that logs are either bad or
+ // overflown
+ Debug(_logger)
+ << "Error reading event log. Exception is " << e.what();
break;
}
}
Module: check_mk
Branch: master
Commit: 71910d09e3e0706c2dba84bb98adac320599aa1c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=71910d09e3e070…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Dec 4 14:12:20 2018 +0100
Improve GUI logging
* The GUI log (var/log/web.log) can now contain log entries from all
python modules that are used during GUI python code processing.
* Initialize logging to web.log not only for "cmk.gui" logger but
also for the top level root logger.
* Initialize top level logger levels with the configured overall GUI
log level.
Change-Id: I2086f7603819134afebb0a44c059f5ff674c613d
---
cmk/gui/log.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/cmk/gui/log.py b/cmk/gui/log.py
index b5d32b7..17dc101 100644
--- a/cmk/gui/log.py
+++ b/cmk/gui/log.py
@@ -64,14 +64,22 @@ def init_logging():
def _setup_web_log_logging():
- del logger.handlers[:] # First remove all handlers
+ del logger.root.handlers[:] # First remove all handlers
handler = _logging.FileHandler("%s/web.log" % cmk.paths.log_dir, encoding="UTF-8")
handler.setFormatter(cmk.log.get_formatter())
- logger.addHandler(handler)
+
+ # Setup logging for the root logger to be able to get library log entries in the
+ # log of the web application
+ logger.root.addHandler(handler)
def set_log_levels(log_levels):
+ # Setup logging for the root logger to be able to get library log entries in the
+ # log of the web application
+ logger.root.setLevel(log_levels["cmk.web"])
+ cmk.log.logger.setLevel(log_levels["cmk.web"])
+
for logger_name, level in log_levels.items():
_logging.getLogger(logger_name).setLevel(level)
Module: check_mk
Branch: master
Commit: 6aa4a181a94e4fa95623b5b5552e7474bdcb0421
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6aa4a181a94e4f…
Author: Óscar Nájera <on(a)mathias-kettner.de>
Date: Wed Nov 21 14:15:22 2018 +0100
6654 FIX Bug fixing in predictive levels and refactoring
Predictive levels calculations suffered from some buggy behaviors under
certain configuration conditions like: no predictions after 22:30,
inhability to fetch data despite months of available perf data, prediction
pointer offset by an hour in timezones with dayligth savings time.
- Document current behavior of get_rrd_data, add test for it, in case it is
ever modified.
- Since livestatus always replies, elevate exception of no data available
to data consolidation function. Should fix symptoms of [FEED-369]
- [CMK-1368] Fix integer division when estimating scale resolution. Now all
time resolutions are correctly mapped to the desired/available time range
- [FEED-3133] Fix predictive monitoring timezone issue
- Use JSON format to store and read prediction data aggregate & info. JSON
is 7x faster that ast.literal_eval and it is safer. Tuple data type is
lost, thus when comparing to parameters config a conversion needs to take
place.
- Functions in cmk_base/prediction are split in smaller more testable units
- Unit test for data processing functions in predictive levels
- Integration test for data retrieval & aggregation for predictive levels
- Include a sample rrd datafile to query historic data and expected
aggregation
- Remove repeated code between cmk_base/prediction & cmk/gui/prediction
Change-Id: I11b134f3d57e7867bba33fb1b926550eb0b489a8
---
.werks/6654 | 13 +
active_checks/check_cpu_peaks | 2 +-
cmk/gui/prediction.py | 119 ++------
cmk/prediction.py | 165 +++++++++++
cmk_base/prediction.py | 321 +++++++++------------
tests/integration/cmk_base/test-files/26 | 1 +
tests/integration/cmk_base/test-files/26.info | 1 +
.../integration/cmk_base/test-files/CPU_load.info | 3 +
tests/integration/cmk_base/test-files/CPU_load.rrd | Bin 0 -> 1151496 bytes
tests/integration/cmk_base/test-files/everyday | 1 +
.../integration/cmk_base/test-files/everyday.info | 1 +
tests/integration/cmk_base/test-files/thursday | 1 +
.../integration/cmk_base/test-files/thursday.info | 1 +
.../cmk_base/test_services_prediction.py | 121 ++++++++
tests/unit/cmk/test_prediction_commons.py | 61 ++++
tests/unit/cmk_base/test_prediction.py | 99 +++----
16 files changed, 566 insertions(+), 344 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=6aa4a181a9…
Module: check_mk
Branch: master
Commit: 583f402a470e472626a69b0bb9d9b907cf2e13ca
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=583f402a470e47…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Dec 3 16:00:06 2018 +0100
Small steps towards enabling wrong-import-position.
Change-Id: I47b324ef4bdd01a82b83618f018c2071dca1daca
---
agents/plugins/mk_tinkerforge | 6 +++---
agents/special/agent_tinkerforge | 6 +++---
bin/check_mk | 4 +++-
bin/mkbackup | 4 ++--
cmk/gui/key_mgmt.py | 4 +++-
cmk/gui/plugins/views/utils.py | 3 +--
cmk_base/packaging.py | 3 +--
tests/pylint/test_pylint.py | 4 ++--
8 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/agents/plugins/mk_tinkerforge b/agents/plugins/mk_tinkerforge
index 865df75..3ee5d8e 100755
--- a/agents/plugins/mk_tinkerforge
+++ b/agents/plugins/mk_tinkerforge
@@ -63,6 +63,9 @@
import sys
import os
+from optparse import OptionParser
+import time
+
def install():
dest = os.path.dirname(os.path.realpath(__file__))
@@ -96,9 +99,6 @@ DEFAULT_SETTINGS = {
'segment_display_brightness': 2
}
-from optparse import OptionParser
-import time
-
# globals
segment_display_value = None
segment_display_unit = ""
diff --git a/agents/special/agent_tinkerforge b/agents/special/agent_tinkerforge
index 7b6744c..b42b810 100755
--- a/agents/special/agent_tinkerforge
+++ b/agents/special/agent_tinkerforge
@@ -59,6 +59,9 @@
import os
+from optparse import OptionParser
+import time
+
DEFAULT_SETTINGS = {
'host': "localhost",
'port': 4223,
@@ -66,9 +69,6 @@ DEFAULT_SETTINGS = {
'segment_display_brightness': 2
}
-from optparse import OptionParser
-import time
-
# globals
segment_display_value = None
segment_display_unit = ""
diff --git a/bin/check_mk b/bin/check_mk
index f087e30..5dc93b9 100755
--- a/bin/check_mk
+++ b/bin/check_mk
@@ -36,7 +36,9 @@ import sys
import getopt
# Needs to be placed before cmk modules, because they are not available
-# when executed as non site user.
+# when executed as non site user. Alas, this screws up our import ordering
+# a bit, so we have to tell pylint about that.
+# pylint: disable=wrong-import-position
if not os.environ.get("OMD_SITE"):
sys.stderr.write("Check_MK can be used only as site user.\n")
sys.exit(1)
diff --git a/bin/mkbackup b/bin/mkbackup
index 213173c..5c59f81 100755
--- a/bin/mkbackup
+++ b/bin/mkbackup
@@ -24,8 +24,6 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-VERSION = "1.4.0i1"
-
import ast
import errno
import fcntl
@@ -61,6 +59,8 @@ import cmk.schedule as schedule
import cmk.store as store
from cmk.exceptions import MKTerminate, MKGeneralException
+VERSION = "1.4.0i1"
+
# Is used to duplicate output from stdout/stderr to a the job log. This
# is e.g. used during "mkbackup backup" to store the output.
diff --git a/cmk/gui/key_mgmt.py b/cmk/gui/key_mgmt.py
index 561fbd5..4f052e0 100644
--- a/cmk/gui/key_mgmt.py
+++ b/cmk/gui/key_mgmt.py
@@ -30,8 +30,10 @@ import time
# This is needed for at least CentOS 5.5
# TODO: Drop this until all supported platforms have newer versions available.
+# It it not 100% sure if we need this before the OpenSSL import, but we play
+# safe here and tell pylint about that.
+# pylint: disable=wrong-import-position
os.environ["CRYPTOGRAPHY_ALLOW_OPENSSL_098"] = "1"
-
from OpenSSL import crypto
import cmk.render
diff --git a/cmk/gui/plugins/views/utils.py b/cmk/gui/plugins/views/utils.py
index 385acdb..f4c3b63 100644
--- a/cmk/gui/plugins/views/utils.py
+++ b/cmk/gui/plugins/views/utils.py
@@ -51,6 +51,7 @@ from cmk.gui.htmllib import HTML
from cmk.gui.i18n import _
from cmk.gui.globals import html
from cmk.gui.exceptions import MKGeneralException
+from cmk.gui.display_options import display_options
# TODO: Better name it PainterOptions or DisplayOptions? There are options which only affect
@@ -293,8 +294,6 @@ def view_title(view):
return visuals.visual_title('view', view)
-from cmk.gui.display_options import display_options
-
# TODO: Move this to view processing code. This must not be module global as
# it contains request specific information
painter_options = PainterOptions()
diff --git a/cmk_base/packaging.py b/cmk_base/packaging.py
index 4cbd9a6..ae55be4 100644
--- a/cmk_base/packaging.py
+++ b/cmk_base/packaging.py
@@ -39,10 +39,9 @@ import cmk.paths
import cmk.ec.export
import cmk.log
-logger = cmk.log.get_logger(__name__)
-
import cmk_base.utils
+logger = cmk.log.get_logger(__name__)
pac_ext = ".mkp"
diff --git a/tests/pylint/test_pylint.py b/tests/pylint/test_pylint.py
index 8312049..1a8d795 100755
--- a/tests/pylint/test_pylint.py
+++ b/tests/pylint/test_pylint.py
@@ -127,7 +127,7 @@ def inv_tree(path, default_value=None):
# add the modules
# These pylint warnings are incompatible with our "concatenation technology".
- f.write("# pylint: disable=reimported,ungrouped-imports,wrong-import-order\n")
+ f.write("# pylint: disable=reimported,ungrouped-imports,wrong-import-order,wrong-import-position\n")
pylint_cmk.add_file(f, repo_path() + "/cmk_base/check_api.py")
pylint_cmk.add_file(f, repo_path() + "/cmk_base/inventory_plugins.py")
@@ -146,7 +146,7 @@ def _compile_bakery_plugins(pylint_test_dir):
pylint_cmk.add_file(
f, os.path.realpath(os.path.join(cmc_path(), "cmk_base/cee/agent_bakery_plugins.py")))
# This pylint warning is incompatible with our "concatenation technology".
- f.write("# pylint: disable=reimported,wrong-import-order\n")
+ f.write("# pylint: disable=reimported,wrong-import-order,wrong-import-position\n")
# Also add bakery plugins
for path in pylint_cmk.check_files(os.path.join(cmc_path(), "agents/bakery")):