Module: check_mk
Branch: master
Commit: c002c24d0d47fa1f5c99eb0cdb62c46c369ad4f7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c002c24d0d47fa…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Jun 14 15:07:47 2017 +0200
4830 FIX IP lookup cache: Fixed bug were updated ipaddress was overwritten by old cached data
Change-Id: Ic389773dc1150a3cdbeb6c2a21a51949a25bfe6a
---
.werks/4830 | 10 ++++++++++
modules/check_mk.py | 35 ++++++++++++++++++++++++-----------
2 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/.werks/4830 b/.werks/4830
new file mode 100644
index 0000000..9cb1c59
--- /dev/null
+++ b/.werks/4830
@@ -0,0 +1,10 @@
+Title: IP lookup cache: Fixed bug were updated ipaddress was overwritten by old cached data
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1497445612
+Class: fix
+
+
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 54383b6..161a2b1 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -2197,8 +2197,7 @@ def cached_dns_lookup(hostname, family):
# Update our cached address if that has changed or was missing
if ipa != cached_ip:
console.verbose("Updating IPv%d DNS cache for %s: %s\n" % (family, hostname, ipa))
- ip_lookup_cache[cache_id] = ipa
- write_ip_lookup_cache()
+ update_ip_lookup_cache(cache_id, ipa)
cache[cache_id] = ipa # Update in-memory-cache
return ipa
@@ -2273,11 +2272,7 @@ def initialize_ip_lookup_cache():
ip_lookup_cache.update(data_from_file)
# be compatible to old caches which were created by Check_MK without IPv6 support
- if ip_lookup_cache and type(ip_lookup_cache.keys()[0]) != tuple:
- new_cache = {}
- for key, val in ip_lookup_cache.items():
- new_cache[(key, 4)] = val
- ip_lookup_cache = new_cache
+ convert_legacy_ip_lookup_cache(ip_lookup_cache)
except:
# TODO: Would be better to log it somewhere to make the failure transparent
pass
@@ -2285,20 +2280,38 @@ def initialize_ip_lookup_cache():
return ip_lookup_cache
-def write_ip_lookup_cache():
- ip_lookup_cache = cmk_base.config_cache.get_dict("ip_lookup")
+def convert_legacy_ip_lookup_cache(ip_lookup_cache):
+ if not ip_lookup_cache:
+ return
+
+ # New version has (hostname, ip family) as key
+ if type(ip_lookup_cache.keys()[0]) == tuple:
+ return
+ new_cache = {}
+ for key, val in ip_lookup_cache.items():
+ new_cache[(key, 4)] = val
+ ip_lookup_cache.clear()
+ ip_lookup_cache.update(new_cache)
+
+
+def update_ip_lookup_cache(cache_id, ipa):
+ ip_lookup_cache = cmk_base.config_cache.get_dict("ip_lookup")
- cache_path = cmk.paths.var_dir + '/ipaddresses.cache'
# Read already known data
+ cache_path = cmk.paths.var_dir + '/ipaddresses.cache'
data_from_file = cmk.store.load_data_from_file(cache_path,
default={},
lock=True)
+
+ convert_legacy_ip_lookup_cache(data_from_file)
ip_lookup_cache.update(data_from_file)
- # The lock from the previous call is released in the following function
+ ip_lookup_cache[cache_id] = ipa
+
# (I don't like this)
# TODO: this file always grows... there should be a cleanup mechanism
# maybe on "cmk --update-dns-cache"
+ # The cache_path is already locked from a previous function call..
cmk.store.save_data_to_file(cache_path, ip_lookup_cache)
Module: check_mk
Branch: master
Commit: c2ad7ce9df2ffb46156b3b588081f705ff99d346
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c2ad7ce9df2ffb…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jun 14 11:55:29 2017 +0200
Store save_file: Cleanup temporary files when files can not be saved
Change-Id: I9de07f5916cd990d5e5c82a5ae4301e9c6ea5057
---
lib/store.py | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/lib/store.py b/lib/store.py
index b6c7037..6a5b18c 100644
--- a/lib/store.py
+++ b/lib/store.py
@@ -155,7 +155,9 @@ def save_data_to_file(path, data, pretty=True):
def save_file(path, content, mode=0660):
try:
# Normally the file is already locked (when data has been loaded before with lock=True),
- # but lock it just to be sure we have the lock on the file
+ # but lock it just to be sure we have the lock on the file.
+ #
+ # Please note that this already creates the file with 0 bytes (in case it is missing).
aquire_lock(path)
tmp_path = None
@@ -194,6 +196,16 @@ def save_file(path, content, mode=0660):
os.rename(tmp_path, path)
except Exception, e:
+ # In case an exception happens during saving cleanup the tempfile created for writing
+ try:
+ if tmp_path:
+ os.unlink(tmp_path)
+ except IOError, e:
+ if e.errno == 2: # No such file or directory
+ pass
+ else:
+ raise
+
# TODO: How to handle debug mode or logging?
raise MKGeneralException(_("Cannot write configuration file \"%s\": %s") % (path, e))
Module: check_mk
Branch: master
Commit: 1c1b0db728895db11214d72b17531f7cbb746e9e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1c1b0db728895d…
Author: Marcel Schulte <ms(a)mathias-kettner.de>
Date: Wed Jun 14 10:32:24 2017 +0200
4858 FIX omd_apache data collection: fixed issues caused by missing newline at the end of statsfile(s)
Sometimes the apache statsfile(s) can miss a newline at the end of the file. This caused the following known issues:
* missing agent section directly after omd_apache section - because the section header was starting in the same line as the omd_apache section's last line
* crashed omd_apache check because of missing data
---
.werks/4858 | 13 +++++++++++++
agents/check_mk_agent.linux | 2 ++
2 files changed, 15 insertions(+)
diff --git a/.werks/4858 b/.werks/4858
new file mode 100644
index 0000000..e70d2de
--- /dev/null
+++ b/.werks/4858
@@ -0,0 +1,13 @@
+Title: omd_apache data collection: fixed issues caused by missing newline at the end of statsfile(s)
+Level: 2
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1497428804
+Class: fix
+
+Sometimes the apache statsfile(s) can miss a newline at the end of the file. This caused the following known issues:
+
+* missing agent section directly after omd_apache section - because the section header was starting in the same line as the omd_apache section's last line
+* crashed omd_apache check because of missing data
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 00b4d00..ba6cee1 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -744,6 +744,8 @@ then
echo "[$site]"
cat $statsfile
> $statsfile
+ # prevent next section to fail caused by a missing newline at the end of the statsfile
+ echo
fi
done
fi
Module: check_mk
Branch: master
Commit: f9c6e7632cc3f3fc5d7cf5aa7e856315e766d767
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f9c6e7632cc3f3…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jun 14 10:14:51 2017 +0200
Updated bug entries #2906, #2907
Change-Id: I0faceae41ca92b34f35343f7f9c74b06434137db
---
.bugs/2906 | 21 +++++++++++++++++++++
.bugs/2907 | 10 ++++++++++
2 files changed, 31 insertions(+)
diff --git a/.bugs/2906 b/.bugs/2906
new file mode 100644
index 0000000..b9830b9
--- /dev/null
+++ b/.bugs/2906
@@ -0,0 +1,21 @@
+Title: Cleanup environment handling of OMD sites
+Component: core
+State: open
+Date: 2017-06-14 09:56:25
+Targetversion: 1.5.0
+Class: bug
+
+There need to be two places where the defined environment of all processes of a OMD
+site is set:
+
+a) su - omd
+b) omd: set_environment()
+
+su - omd uses the .profile of a site to initialize the environment. Both places
+differ and should be unified. Maybe a single central file needs to be created
+that holds all the environment variable definitions and both places rely on that
+file.
+
+We also should cleanup the different sourcing calls of OMD daemon init scripts.
+The calls ". .profile" should be removed. All subprocesses created within a site
+need to inherit this defined environment.
diff --git a/.bugs/2907 b/.bugs/2907
new file mode 100644
index 0000000..41c6200
--- /dev/null
+++ b/.bugs/2907
@@ -0,0 +1,10 @@
+Title: Slave sites: Save site specific global settings in sitespecific.mk
+Component: wato
+State: open
+Date: 2017-06-14 10:00:17
+Targetversion: 1.5.0
+Class: bug
+
+This is an inconsistency between the master and the slave site. The slave site receives a sitespecfic.mk
+in the sync snapshot and writes the config to the globals.mk. Instead it should save it in the sitespecific.mk
+and show the site specific global settings button on the distributed monitoring page, just like on the master.
Module: check_mk
Branch: master
Commit: 70efbe6af639077067075bc61f7ace6ae2efc031
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=70efbe6af63907…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jun 14 09:55:39 2017 +0200
4756 FIX Fix possible timeouts when changing configurations or changing user profile properties
Check_MK is using generic functions to perform file IO, for example to save configuration files
of WATO or saving the user properties of the GUI. With 1.4.0b1 we introduced a change that was
intended to prevent loss of just written files during hard OS crashes. This change has now
been reverted because it behaves badly in high IO load situations and might also itself cause
high IO load in case files are written in a high frequency.
The IO behaviour in this situation has now simply been changed back to the old state before
1.4.0b1.
In future releases (1.5+) we'll find a solution to improve the handling of OS crash recovery
situations.
Change-Id: Ic07b8151e419a7cc821b4480f56367da140eb7da
---
.werks/4756 | 21 +++++++++++++++++++++
lib/store.py | 26 ++++++++++++++++++++++++--
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/.werks/4756 b/.werks/4756
new file mode 100644
index 0000000..22a2a75
--- /dev/null
+++ b/.werks/4756
@@ -0,0 +1,21 @@
+Title: Fix possible timeouts when changing configurations or changing user profile properties
+Level: 1
+Component: core
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1497426322
+
+Check_MK is using generic functions to perform file IO, for example to save configuration files
+of WATO or saving the user properties of the GUI. With 1.4.0b1 we introduced a change that was
+intended to prevent loss of just written files during hard OS crashes. This change has now
+been reverted because it behaves badly in high IO load situations and might also itself cause
+high IO load in case files are written in a high frequency.
+
+The IO behaviour in this situation has now simply been changed back to the old state before
+1.4.0b1.
+
+In future releases (1.5+) we'll find a solution to improve the handling of OS crash recovery
+situations.
diff --git a/lib/store.py b/lib/store.py
index 51f4c69..b6c7037 100644
--- a/lib/store.py
+++ b/lib/store.py
@@ -166,8 +166,30 @@ def save_file(path, content, mode=0660):
os.chmod(tmp_path, mode)
tmp.write(content)
- tmp.flush()
- os.fsync(tmp.fileno())
+ # The goal of the fsync would be to ensure that there is a consistent file after a
+ # crash. Without the fsync it may happen that the file renamed below is just an empty
+ # file. That may lead into unexpected situations during loading.
+ #
+ # Don't do a fsync here because this may run into IO performance issues. Even when
+ # we can specify the fsync on a fd, the disk cache may be flushed completely because
+ # the disk does not know anything about fds, only about blocks.
+ #
+ # For Check_MK 1.4 we can not introduce a good solution for this, because the changes
+ # would affect too many parts of Check_MK with possible new issues. For the moment we
+ # stick with the IO behaviour of previous Check_MK versions.
+ #
+ # In the future we'll find a solution to deal better with OS crash recovery situations.
+ # for example like this:
+ #
+ # TODO(lm): The consistency of the file will can be ensured using copies of the
+ # original file which are made before replacing it with the new one. After first
+ # successful loading of the just written fille the possibly existing copies of this
+ # file are deleted.
+ # We can archieve this by calling os.link() before the os.rename() below. Then we need
+ # to define in which situations we want to check out the backup file(s) and in which
+ # cases we can savely delete them.
+ #tmp.flush()
+ #os.fsync(tmp.fileno())
os.rename(tmp_path, path)