Module: check_mk
Branch: master
Commit: 9a796a4ce657aadd7e9b0e5b4a0519f5838bc442
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9a796a4ce657aa…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Mar 6 16:16:04 2014 +0100
Fix remote spooling with RBN
---
doc/treasures/mknotifyd | 9 +++++----
modules/notify.py | 12 ++++++++++--
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/doc/treasures/mknotifyd b/doc/treasures/mknotifyd
index 4b75d8a..b60f791 100755
--- a/doc/treasures/mknotifyd
+++ b/doc/treasures/mknotifyd
@@ -239,6 +239,7 @@ class TcpServer:
client_data = ""
chunk_count = 0
client_socket, addr_info = s.accept()
+ from_name = "%s:%s" % addr_info
while True:
try:
data_ready = select.select([client_socket], [], [], 2)[0]
@@ -254,21 +255,21 @@ class TcpServer:
break # Error while reading
if opt_verbose > 1:
- verbose("Received notification %d from %s in %d chunks" % (
handled_connections, pprint.pformat(addr_info), chunk_count), 2)
+ verbose("Received notification %d from %s in %d chunks" % (
handled_connections, from_name, chunk_count), 2)
handled_connections = handled_connections + 1
try:
content = pickle.loads(client_data)
- del content["forward"]
if not os.path.exists(g_spool_dir):
os.makedirs(g_spool_dir)
- spoolfile = "%s/%s" % uuid.uuid1()
+ spoolfile = "%s/%s" % (g_spool_dir, uuid.uuid1())
file(spoolfile,"w").write(pprint.pformat(content))
verbose("client data processed - sending OK", 2)
client_socket.send("OK")
except Exception, e:
- log("Error processing data from %s" %
pprint.pformat(addr_info))
+
+ log("Error processing data from %s: %s\n%s" % (from_name,
e, format_exception()))
try:
if client_socket:
client_socket.send("ERROR")
diff --git a/modules/notify.py b/modules/notify.py
index 590058f..f57e5be 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -544,7 +544,15 @@ def rbn_add_contact_information(raw_context, contact):
if key[0] == '_':
raw_context["CONTACT" + key.upper()] = contact[key]
else:
- contact_dict = contacts.get(contact, { "name" : contact,
"alias" : contact })
+ if contact.startswith("mailto:"): # Fake contact
+ contact_dict = {
+ "name" : contact[7:].split("@")[0],
+ "alias" : "Email address " + contact,
+ "email" : contact[7:],
+ "pager" : "" }
+ else:
+ contact_dict = contacts.get(contact, { "name" : contact,
"alias" : contact })
+
rbn_add_contact_information(raw_context, contact_dict)
@@ -1186,7 +1194,7 @@ def handle_spoolfile(spoolfile):
# several or no actual plugins.
notify_log("Got spool file from remote host for local delivery.")
raw_context = data["context"]
- locally_deliver_plugin_context(data["context"])
+ locally_deliver_raw_context(data["context"])
return 0 # No error handling for async delivery
except Exception, e: