Module: check_mk
Branch: master
Commit: 6301927d1c9bd2e5d4508f2a479f137536aee022
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6301927d1c9bd2…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jan 18 19:23:48 2017 +0100
livestatus: Fixed exception in case no timeout was set
Change-Id: I378c19333dc8339133dce104897d09b40a80213d
---
livestatus/api/python/livestatus.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/livestatus/api/python/livestatus.py b/livestatus/api/python/livestatus.py
index afcf0dc..45f521a 100644
--- a/livestatus/api/python/livestatus.py
+++ b/livestatus/api/python/livestatus.py
@@ -344,15 +344,19 @@ class BaseConnection:
else:
raise MKLivestatusQueryError("%s: %s" % (code, data.strip()))
- # In case of an IO error or the other side having
- # closed the socket do a reconnect and try again, but
- # only once
except (MKLivestatusSocketClosed, IOError), e:
+ # In case of an IO error or the other side having
+ # closed the socket do a reconnect and try again
self.disconnect()
now = time.time()
if query and (not timeout_at or timeout_at > now):
if timeout_at == None:
- timeout_at = now + self.timeout
+ # Try until timeout reached in case there was a timeout configured.
+ # Otherwise only retry once.
+ timeout_at = now
+ if self.timeout:
+ timeout_at += self.timeout
+
time.sleep(0.1)
self.connect()
self.send_query(query, add_headers)
Module: check_mk
Branch: master
Commit: 49be7d681456d644d1c1c8d1b19de49f734d6f78
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=49be7d681456d6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jan 19 10:31:23 2017 +0100
4281 FIX Fixed piggyback hosts with spaces in names leading to crashes
It was possible for agent plugins / special agents to create piggyback hosts
with spaces in their names which lead to crashes of Check_MK check helpers
when trying to check these hosts.
These spaces will now automatically be replaced by underscores to workaround
this issue. In case you want to have another replacement logic, you can use
the piggyback translation ruleset to override the default behaviour.
Change-Id: I8c0ff0e93bef3323f9b181dc41585c35c4a3f84b
---
.werks/4281 | 15 +++++++++++++++
ChangeLog | 1 +
modules/check_mk_base.py | 8 ++++++++
3 files changed, 24 insertions(+)
diff --git a/.werks/4281 b/.werks/4281
new file mode 100644
index 0000000..2455c30
--- /dev/null
+++ b/.werks/4281
@@ -0,0 +1,15 @@
+Title: Fixed piggyback hosts with spaces in names leading to crashes
+Level: 1
+Component: core
+Compatible: compat
+Version: 1.4.0i4
+Date: 1484818031
+Class: fix
+
+It was possible for agent plugins / special agents to create piggyback hosts
+with spaces in their names which lead to crashes of Check_MK check helpers
+when trying to check these hosts.
+
+These spaces will now automatically be replaced by underscores to workaround
+this issue. In case you want to have another replacement logic, you can use
+the piggyback translation ruleset to override the default behaviour.
diff --git a/ChangeLog b/ChangeLog
index a72ea66..7dc1287 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
1.4.0i4:
Core & Setup:
* 4269 FIX: Verifying unexpected keys in check_info while loading checks...
+ * 4281 FIX: Fixed piggyback hosts with spaces in names leading to crashes...
Checks & Agents:
* 4104 veeam_tapejobs: New check to monitor Veeam tape jobs
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index b68e266..9fc1546 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -899,6 +899,14 @@ def parse_info(lines, hostname):
host = translate_piggyback_host(hostname, host)
if host == hostname:
host = None # unpiggybacked "normal" host
+
+ # Protect Check_MK against unallowed host names. Normally source scripts
+ # like agent plugins should care about cleaning their provided host names
+ # up, but we need to be sure here to prevent bugs in Check_MK code.
+ # a) Replace spaces by underscores
+ if host:
+ host = host.replace(" ", "_")
+
elif host: # processing data for an other host
piggybacked.setdefault(host, []).append(line)