Module: check_mk
Branch: master
Commit: e71c79b6899e1ad95d3a4a03eed6973ca118dd23
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e71c79b6899e1a…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon May 6 13:15:16 2019 +0200
WK7259: Fixed bug with host discovery causing steadily increasing CPU load on the
monitoring system
Change-Id: I34b120ddf0ebd37c4836cd90adc425a1ec6e35a8
---
.werks/7259 | 16 ++++++++++++++++
cmk_base/discovery.py | 14 ++++++++------
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/.werks/7259 b/.werks/7259
new file mode 100644
index 0000000..8a857cb
--- /dev/null
+++ b/.werks/7259
@@ -0,0 +1,16 @@
+Title: Fixed bug with host discovery causing steadily increasing CPU load on the
monitoring system.
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1557135736
+
+A host service discovery could modify the monitoring cores live configuration.
+The monitoring core detects this deviation and restarts the Check_MK helper.
+However, the restarted helper uses the new configuration, whereas the core still uses the
old configuration - causing another restart...
+
+This has been fixed.
+
diff --git a/cmk_base/discovery.py b/cmk_base/discovery.py
index f915759..90b9918 100644
--- a/cmk_base/discovery.py
+++ b/cmk_base/discovery.py
@@ -29,6 +29,7 @@ import socket
import time
import signal
from typing import Callable, List, Text, Optional, Dict, Tuple # pylint:
disable=unused-import
+import pathlib2 as pathlib
from cmk.utils.regex import regex
import cmk.utils.tty as tty
@@ -1332,16 +1333,17 @@ def _remove_autochecks_file(hostname):
pass
-# FIXME TODO: Consolidate with automation.py automation_write_autochecks_file()
def _save_autochecks_file(hostname, items):
if not os.path.exists(cmk.utils.paths.autochecks_dir):
os.makedirs(cmk.utils.paths.autochecks_dir)
- filepath = "%s/%s.mk" % (cmk.utils.paths.autochecks_dir, hostname)
- out = file(filepath, "w")
- out.write("[\n")
+
+ filepath = pathlib.Path() / cmk.utils.paths.autochecks_dir / ("%s.mk" %
hostname)
+ content = []
+ content.append("[")
for check_plugin_name, item, paramstring in items:
- out.write(" (%r, %r, %s),\n" % (check_plugin_name, item,
paramstring))
- out.write("]\n")
+ content.append(" (%r, %r, %s)," % (check_plugin_name, item,
paramstring))
+ content.append("]\n")
+ store.save_file(str(filepath), "\n".join(content))
def set_autochecks_of(host_config, new_items):