Module: check_mk
Branch: master
Commit: b8446f49de1f1cc94e35243efc66cada1e481676
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b8446f49de1f1c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jan 25 17:17:37 2013 +0100
logwatch.ec: use unix socket instead of pipe
This fixes a race condition when two checks run exactly at the
same time.
---
checks/logwatch | 9 +++++----
web/plugins/wato/check_parameters.py | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/checks/logwatch b/checks/logwatch
index bae6758..a8a0706 100644
--- a/checks/logwatch
+++ b/checks/logwatch
@@ -446,7 +446,7 @@ def check_logwatch_ec(_unused, params, info):
# d) remote via tcp
method = params.get('method')
if method == None:
- method = os.getenv('OMD_ROOT') + "/tmp/run/mkeventd/events"
+ method = os.getenv('OMD_ROOT') +
"/tmp/run/mkeventd/eventsocket"
try:
if isinstance(method, tuple):
@@ -466,9 +466,10 @@ def check_logwatch_ec(_unused, params, info):
# is *not* existing! This prevents us from hanging in such
# situations. So we must make sure that we do not create a file
# instead of the pipe!
- pipe = os.open(method, os.O_WRONLY)
- os.write(pipe, '\n'.join(messages))
- os.close(pipe)
+ sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ sock.connect(method)
+ sock.send('\n'.join(messages))
+ sock.close()
num_messages = len(messages)
return (0, 'OK - Forwarded %d messages to event console' % num_messages,
[('messages', num_messages)])
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 1a6b6d2..a3b1529 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -2222,7 +2222,7 @@ checkgroups.append((
title = _("Send events to local event console in same OMD
site"),
),
TextAscii(
- title = _("Send events to local event console into
pipe"),
+ title = _("Send events to local event console into unix
socket"),
allow_empty = False,
),
Tuple(