Module: check_mk
Branch: master
Commit: e02d3e6e7c68815014b7e4f24843d2defbe7d3e4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e02d3e6e7c6881…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Dec 4 09:49:47 2017 +0100
5248 FIX diskspace cleanup: No longer deletes agent updater registration files of hosts
monitored in foreign sites
The diskspace cleanup routine regularly deleted files of hosts which did not belong to the
current site.
Change-Id: I497b01052f42ba5ca6deb1bba5bfdd66c4665932
---
.werks/5248 | 11 +++++++++++
omd/packages/maintenance/diskspace | 17 +++++++++++++----
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/.werks/5248 b/.werks/5248
new file mode 100644
index 0000000..6ca6794
--- /dev/null
+++ b/.werks/5248
@@ -0,0 +1,11 @@
+Title: diskspace cleanup: No longer deletes agent updater registration files of hosts
monitored in foreign sites
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i2
+Date: 1512377354
+Class: fix
+
+The diskspace cleanup routine regularly deleted files of hosts which did not belong to
the current site.
+
diff --git a/omd/packages/maintenance/diskspace b/omd/packages/maintenance/diskspace
index 9824482..a8c5459 100755
--- a/omd/packages/maintenance/diskspace
+++ b/omd/packages/maintenance/diskspace
@@ -238,7 +238,7 @@ def do_cleanup_abandoned_host_files():
return
try:
- site_hosts = get_site_hosts()
+ site_hosts = get_configured_hosts()
except subprocess.CalledProcessError, e:
verbose("Failed to get site hosts (%s). Skipping abandoned host files
cleanup" % e)
return
@@ -304,10 +304,19 @@ def newest_modification_time_in_dir(dir_path):
return mtime
-def get_site_hosts():
+def get_configured_hosts():
host_names = set([])
- host_names.update(subprocess.check_output(["check_mk",
"--list-hosts"]).splitlines())
- host_names.update(subprocess.check_output(["check_mk",
"--list-tag", "offline"]).splitlines())
+
+ distr_wato_filepath =
os.path.expanduser("~/etc/check_mk/conf.d/distributed_wato.mk")
+ file_vars = {}
+ if os.path.exists(distr_wato_filepath):
+ execfile(distr_wato_filepath, file_vars, file_vars)
+
+ if file_vars.get("is_wato_slave_site", False):
+ host_names.update(subprocess.check_output(["check_mk",
"--list-hosts", "--include-offline"]).splitlines())
+ else:
+ host_names.update(subprocess.check_output(["check_mk",
"--list-hosts", "--all-sites",
"--include-offline"]).splitlines())
+
return host_names