Connection reset by peer" when reloading Event Console
Message-ID: <557abe46.upsJkCQgAgmNLcqL%mk(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 219de74d002d805c6f4411826b90f36d08753189
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=219de74d002d80…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jun 12 13:10:57 2015 +0200
#2328 FIX Fix sporadic error "Connection reset by peer" when reloading Event
Console
The problem appeared especially when distributing changes with WATO in a
distributed setup. The reason was: the reload of the configuration closed
and reopened the UNIX socket that is used for sending commands. That way
parallel connections would be closed. Now the UNIX socket is only reopened
when the configuration parameter <i>Max. number of pending connections to
the status socket</i> has changed and a reload is thus neccessary in order
to make that change active.
---
.werks/2328 | 16 ++++++++++++++++
ChangeLog | 1 +
mkeventd/bin/mkeventd | 26 ++++++++++++++++++++++----
3 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/.werks/2328 b/.werks/2328
new file mode 100644
index 0000000..1d6261b
--- /dev/null
+++ b/.werks/2328
@@ -0,0 +1,16 @@
+Title: Fix sporadic error "Connection reset by peer" when reloading Event
Console
+Level: 2
+Component: ec
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i2
+Date: 1434107286
+
+The problem appeared especially when distributing changes with WATO in a
+distributed setup. The reason was: the reload of the configuration closed
+and reopened the UNIX socket that is used for sending commands. That way
+parallel connections would be closed. Now the UNIX socket is only reopened
+when the configuration parameter <i>Max. number of pending connections to
+the status socket</i> has changed and a reload is thus neccessary in order
+to make that change active.
diff --git a/ChangeLog b/ChangeLog
index 731dae9..a9e1ffa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -48,6 +48,7 @@
* 2333 The Event Console log level can now be configured via GUI...
* 2334 Logging details about loaded SNMP MIB modules during startup
* 2326 Allow relating Event Console hosts to monitoring hosts now also by alias...
+ * 2328 FIX: Fix sporadic error "Connection reset by peer" when reloading
Event Console...
1.2.7i1:
diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd
index 9818f71..83f09c0 100755
--- a/mkeventd/bin/mkeventd
+++ b/mkeventd/bin/mkeventd
@@ -2374,6 +2374,10 @@ class StatusServer:
self.open_sockets()
def open_sockets(self):
+ self.open_unix_socket()
+ self.open_tcp_socket()
+
+ def open_unix_socket(self):
if os.path.exists(g_socket_path):
os.remove(g_socket_path)
self._socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@@ -2381,7 +2385,9 @@ class StatusServer:
# Make sure that socket is group writable
os.chmod(g_socket_path, 0664)
self._socket.listen(g_config['socket_queue_len'])
+ self._unix_socket_queue_len = g_config['socket_queue_len'] # detect
changes in config
+ def open_tcp_socket(self):
if g_config["remote_status"]:
try:
self._tcp_port, self._tcp_allow_commands =
g_config["remote_status"][:2]
@@ -2406,13 +2412,28 @@ class StatusServer:
self._tcp_access_list = None
def close_sockets(self):
+ self.close_tcp_socket()
+ self.close_unix_socket()
+
+ def close_unix_socket(self):
if self._socket:
self._socket.close()
self._socket = None
+
+ def close_tcp_socket(self):
if self._tcp_socket:
self._tcp_socket.close()
self._tcp_socket = None
+ def reopen_sockets(self):
+ if self._unix_socket_queue_len != g_config["socket_queue_len"]:
+ log("socket_queue_len has changed. Reopening UNIX socket.")
+ self.close_unix_socket()
+ self.open_unix_socket()
+
+ self.close_tcp_socket()
+ self.open_tcp_socket()
+
def reload_configuration(self):
self._reopen_sockets = True
@@ -2447,10 +2468,7 @@ class StatusServer:
addr_info = None
if self._reopen_sockets:
- if opt_debug:
- log("Reopening sockets")
- self.close_sockets()
- self.open_sockets()
+ self.reopen_sockets()
self._reopen_sockets = False
listen_list = [ self._socket ]