Module: check_mk
Branch: master
Commit: 86478443436fff7f210451182c68dc3239aeaa8d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=86478443436fff…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Apr 4 15:04:40 2013 +0200
Added $HOSTURL$ and $SERVICEURL$ to notification macros
Conflicts:
ChangeLog
modules/notify.py
---
ChangeLog | 5 +++++
modules/notify.py | 9 +++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index af77b74..960f1b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -87,6 +87,11 @@
* Inventory: Display link symbol for ps ruleset
1.2.2:
+ Core:
+ * Added $HOSTURL$ and $SERVICEURL$ to notification macros which contain an
+ URL to the host/service details views with /check_mk/... as base.
+
+1.2.2b7:
Checks & Agents:
* FIX: postfix_mailq: fix labels in WATO rule, set correct default levels
diff --git a/modules/notify.py b/modules/notify.py
index 1a1762f..90ffef5 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -35,6 +35,7 @@
# the form %(variable)s
import pprint
+import urllib
# Default settings
notification_logdir = var_dir + "/notify"
@@ -271,6 +272,9 @@ def process_context(context, write_into_spoolfile, use_method =
None):
sys.stderr.write("Details have been logged to %s.\n" %
notification_log)
sys.exit(2)
+def urlencode(s):
+ return urllib.quote(s)
+
def do_notify(args):
try:
mode = 'notify'
@@ -337,6 +341,11 @@ def do_notify(args):
context["WHAT"] = context.get("SERVICEDESC") and
"SERVICE" or "HOST"
context["MAIL_COMMAND"] = notification_mail_command
+ context['HOSTURL'] =
'/check_mk/view.py?view_name=hoststatus&host=%s' %
urlencode(context['HOSTNAME'])
+ if context['WHAT'] == 'SERVICE':
+ context['SERVICEURL'] =
'/check_mk/view.py?view_name=service&host=%s&service=%s' % \
+ (urlencode(context['HOSTNAME']),
urlencode(context['SERVICEDESC']))
+
# Handle interactive calls
if mode == 'fake-service':
set_fake_env('service', context)