Module: check_mk
Branch: master
Commit: a6945e24673286bd44232f4d143a3d91da088a07
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a6945e24673286…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Mar 4 11:43:41 2015 +0100
notify.log: log host name and service for each new notification
---
modules/notify.py | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/modules/notify.py b/modules/notify.py
index c3b4e6b..b636611 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -205,9 +205,11 @@ def notify_notify(raw_context, analyse=False):
notify_log("----------------------------------------------------------------------")
if analyse:
- notify_log("Analysing notification context with %s variables" %
len(raw_context))
+ notify_log("Analysing notification (%s) context with %s variables" % (
+ find_host_service(raw_context), len(raw_context)))
else:
- notify_log("Got raw notification context with %s variables" %
len(raw_context))
+ notify_log("Got raw notification (%s) context with %s variables" % (
+ find_host_service(raw_context), len(raw_context)))
# Add some further variable for the conveniance of the plugins
@@ -1400,13 +1402,14 @@ def create_spoolfile(data):
# 3. Notifications to *got* forwarded. Contain neither of both.
# Spool files of type 1 are not handled here!
def handle_spoolfile(spoolfile):
+
notify_log("----------------------------------------------------------------------")
try:
data = eval(file(spoolfile).read())
if "plugin" in data:
plugin_context = data["context"]
plugin = data["plugin"]
- notify_log("Got spool file for local delivery via %s" % (
- plugin or "plain mail"))
+ notify_log("Got spool file (%s) for local delivery via %s" % (
+ find_host_service(plugin_context), (plugin or "plain mail")))
return call_notification_script(plugin, plugin_context)
else:
@@ -1873,6 +1876,13 @@ def substitute_context(template, context):
# | Some generic helper functions |
# '----------------------------------------------------------------------'
+def find_host_service(context):
+ host = context.get("HOSTNAME", "UNKNOWN")
+ service = context.get("SERVICEDESC")
+ if service:
+ return host + ";" + service
+ else:
+ return host
def livestatus_fetch_query(query):
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)