Module: check_mk
Branch: master
Commit: c0c9f6d842e2b3c6268cc4a67d72019b0410b0fb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c0c9f6d842e2b3…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Apr 7 14:21:03 2014 +0200
Added variables LASTHOSTUP_REL and LASTSERVICEOK_REL to notification context
These two variables can now be used in notification scripts.
---
.werks/755 | 8 ++++++++
ChangeLog | 1 +
modules/notify.py | 10 +++++-----
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/.werks/755 b/.werks/755
new file mode 100644
index 0000000..e41ce62
--- /dev/null
+++ b/.werks/755
@@ -0,0 +1,8 @@
+Title: Added variables LASTHOSTUP_REL and LASTSERVICEOK_REL to notification context
+Level: 1
+Component: notifications
+Version: 1.2.5i3
+Date: 1396873229
+Class: feature
+
+These two variables can now be used in notification scripts.
diff --git a/ChangeLog b/ChangeLog
index e6f3b02..a2f5784 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,7 @@
Notifications:
* 0754 Allow users to disable their notifications completely...
+ * 0755 Added variables LASTHOSTUP_REL and LASTSERVICEOK_REL to notification
context...
* 0752 FIX: FIX: compute correct state transitions for notifications...
* 0753 FIX: FIX: correctly show original state in HTML notification mails...
diff --git a/modules/notify.py b/modules/notify.py
index 80f98ea..06da82f 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -1507,11 +1507,11 @@ def complete_raw_context(raw_context):
urlencode('view.py?view_name=service&host=%s&service=%s' %
(raw_context['HOSTNAME'],
raw_context['SERVICEDESC']))
- # Relative Timestamps for host/service state changes
- if 'LASTHOSTSTATECHANGE' in raw_context:
- raw_context['LASTHOSTSTATECHANGE_REL'] =
get_readable_rel_date(raw_context['LASTHOSTSTATECHANGE'])
- if raw_context['WHAT'] != 'HOST' and 'LASTSERVICESTATECHANGE'
in raw_context:
- raw_context['LASTSERVICESTATECHANGE_REL'] =
get_readable_rel_date(raw_context['LASTSERVICESTATECHANGE'])
+ # Relative Timestamps for several macros
+ for macro in [ 'LASTHOSTSTATECHANGE', 'LASTSERVICESTATECHANGE',
'LASTHOSTUP', 'LASTSERVICEOK' ]:
+ if macro in raw_context:
+ raw_context[macro + '_REL'] =
get_readable_rel_date(raw_context[macro])
+
# Rule based notifications enabled? We might need to complete a few macros
contact = raw_context.get("CONTACTNAME")