Module: check_mk
Branch: master
Commit: b465fedec21f358155f5aed0042bb18b94854ce4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b465fedec21f35…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Oct 19 13:19:29 2016 +0200
3965 FIX Nagios: Improved handling of broken core config
In case of configuration validation issues, the broken config, which
will be replaced by the former config on validation issues, is copied
to /omd/sites/[site]/tmp/check_mk/check_mk_objects.cfg.broken for
diagnose actions.
---
.werks/3965 | 12 ++++++++++++
ChangeLog | 1 +
modules/automation.py | 7 ++++++-
modules/check_mk.py | 5 +++++
4 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/.werks/3965 b/.werks/3965
new file mode 100644
index 0000000..20cecaf
--- /dev/null
+++ b/.werks/3965
@@ -0,0 +1,12 @@
+Title: Nagios: Improved handling of broken core config
+Level: 1
+Component: core
+Compatible: compat
+Version: 1.4.0i2
+Date: 1476875916
+Class: fix
+
+In case of configuration validation issues, the broken config, which
+will be replaced by the former config on validation issues, is copied
+to /omd/sites/[site]/tmp/check_mk/check_mk_objects.cfg.broken for
+diagnose actions.
diff --git a/ChangeLog b/ChangeLog
index fd5524d..13d5533 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
1.4.0i2:
Core & Setup:
* 3648 FIX: Fixed log file parsing of host states...
+ * 3965 FIX: Nagios: Improved handling of broken core config...
Checks & Agents:
* 3841 cups_queues: thresholds are now configurable in WATO...
diff --git a/modules/automation.py b/modules/automation.py
index 0768f98..ae3e026 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -502,11 +502,16 @@ def automation_restart(job = "restart"):
do_precompile_hostchecks()
do_core_action(job)
else:
+ broken_config_path = "%s/check_mk_objects.cfg.broken" %
cmk.paths.tmp_dir
+ file(broken_config_path,
"w").write(file(cmk.paths.nagios_objects_file).read())
+
if backup_path:
os.rename(backup_path, objects_file)
else:
os.remove(objects_file)
- raise MKAutomationError("Configuration for monitoring core is invalid.
Rolling back.")
+ raise MKAutomationError(
+ "Configuration for monitoring core is invalid. Rolling back. "
+ "The broken file has been copied to \"%s\" for
analysis." % broken_config_path)
except Exception, e:
if backup_path and os.path.exists(backup_path):
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 9c7eccc..fe9f34e 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -3868,6 +3868,11 @@ def do_restart(only_reload = False):
do_core_action(only_reload and "reload" or "restart")
else:
sys.stderr.write("Configuration for monitoring core is invalid. Rolling
back.\n")
+
+ broken_config_path = "%s/check_mk_objects.cfg.broken" %
cmk.paths.tmp_dir
+ file(broken_config_path,
"w").write(file(cmk.paths.nagios_objects_file).read())
+ sys.stderr.write("The broken file has been copied to \"%s\"
for analysis.\n" % broken_config_path)
+
if backup_path:
os.rename(backup_path, cmk.paths.nagios_objects_file)
else: