Module: check_mk
Branch: master
Commit: dd048d6b8a83ea3f984d90e905d931d8146b7bc8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dd048d6b8a83ea…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jan 17 11:57:06 2018 +0100
5651 FIX Fixed agent TCP connect timeout being used for whole communication (1.5.0i2
regression)
The configurable "Agent TCP connect timeout" was used not only for the connect
phase of
the TCP connection. This lead to many timeout messages like
"agent:myhost:12.16.11.42: timed out".
Change-Id: Iff28663cbc8542181844d90b05387fb701321958
---
.werks/5651 | 11 +++++++++++
cmk_base/data_sources/tcp.py | 8 ++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/.werks/5651 b/.werks/5651
new file mode 100644
index 0000000..9f552c2
--- /dev/null
+++ b/.werks/5651
@@ -0,0 +1,11 @@
+Title: Fixed agent TCP connect timeout being used for whole communication (1.5.0i2
regression)
+Level: 1
+Component: core
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1516186453
+Class: fix
+
+The configurable "Agent TCP connect timeout" was used not only for the connect
phase of
+the TCP connection. This lead to many timeout messages like
"agent:myhost:12.16.11.42: timed out".
diff --git a/cmk_base/data_sources/tcp.py b/cmk_base/data_sources/tcp.py
index f827855..215d58b 100644
--- a/cmk_base/data_sources/tcp.py
+++ b/cmk_base/data_sources/tcp.py
@@ -96,12 +96,16 @@ class TCPDataSource(CheckMKAgentDataSource):
s = socket.socket(socktype, socket.SOCK_STREAM)
timeout = self._get_timeout(hostname)
- s.settimeout(timeout)
output = []
- self._logger.debug("[%s] Connecting via TCP to %s:%d (%ss timeout)" %
(self.id(), ipaddress, port, s.gettimeout()))
+ self._logger.debug("[%s] Connecting via TCP to %s:%d (%ss timeout)" %
(self.id(), ipaddress, port, timeout))
try:
+ s.settimeout(timeout)
s.connect((ipaddress, port))
+ s.settimeout(None)
+
+ self._logger.debug("[%s] Reading data from agent" % (self.id()))
+
while True:
data = s.recv(4096, socket.MSG_WAITALL)