Module: check_mk
Branch: master
Commit: 64a744177da6020904b4f14d415f9d5bf683cc5e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=64a744177da602…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 5 10:31:19 2013 +0200
Improved html mail implementation - now working in non omd environments
Conflicts:
modules/notify.py
---
ChangeLog | 4 ++++
modules/notify.py | 14 +++++++-------
notifications/mail | 15 +++++++++++----
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 056b979..8818697 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -91,6 +91,10 @@
* Added $HOSTURL$ and $SERVICEURL$ to notification macros which contain an
URL to the host/service details views with /check_mk/... as base.
+ Notifications:
+ * FIX: Removing GRAPH_CODE in html mails when not available
+ * Using plugin argument 1 for path to pnp4nagios index php to render graphs
+
Multisite:
* FIX: Fixed umlaut handling in reloaded snapins
diff --git a/modules/notify.py b/modules/notify.py
index 90ffef5..6b4cdc0 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -341,18 +341,18 @@ 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)
- sys.exit(call_notification_script(plugin, [], context, True))
-
elif mode == 'fake-host':
set_fake_env('host', context)
+
+ 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']))
+
+ if mode in [ 'fake-service', 'fake_host' ]:
sys.exit(call_notification_script(plugin, [], context, True))
if 'LASTHOSTSTATECHANGE' in context:
diff --git a/notifications/mail b/notifications/mail
index 501d490..37d09cb 100755
--- a/notifications/mail
+++ b/notifications/mail
@@ -315,11 +315,16 @@ def send_mail(m, target):
def fetch_pnp_data(context, params):
try:
- prefix_url = "%s/share" % context['OMD_ROOT']
+ # Autodetect the path in OMD environments
+ path = "%s/share/pnp4nagios/htdocs/index.php" %
context['OMD_ROOT']
except:
- # Non-omd environment
- prefix_url = ""
- return os.popen('REMOTE_USER="%s" php %s/pnp4nagios/htdocs/index.php
"%s"' % (context['CONTACTNAME'], prefix_url, params)).read()
+ # Non-omd environment - use plugin argument 1
+ path = context['PARAMETER_1']
+
+ if not os.path.exists(path):
+ raise GraphException('Unable to locate pnp4nagios index.php (%s)' %
path)
+
+ return os.popen('REMOTE_USER="%s" php %s "%s"' %
(context['CONTACTNAME'], path, params)).read()
def fetch_num_sources(context):
svc_desc = context['WHAT'] == 'HOST' and '_HOST_' or
context['SERVICEDESC']
@@ -383,6 +388,8 @@ def main():
'<tr><th colspan=2>Graphs</th></tr>'
'<tr class="data even0"><td colspan=2
class=graphs>%s</td></tr>' % graph_code
)
+ else:
+ context['GRAPH_CODE'] = ''
# Compute the subject of the mail
if context['WHAT'] == 'HOST':