Module: check_mk
Branch: master
Commit: 25a983bf03027fbf0b8c32c869289752d151b8a8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=25a983bf03027f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jan 25 09:11:53 2017 +0100
4284 FIX Nagios: Added missing variable MICROTIME to notification contexts
When using the CMC, the MICROTIME context variable is always present.
This fixes an error when using the pushover notification plugin with the
Nagios core.
Change-Id: I94db106bf2ed0da6f19a9b1a27f361d8ee478ff6
---
.werks/4284 | 11 +++++++++++
ChangeLog | 1 +
modules/events.py | 5 +++++
3 files changed, 17 insertions(+)
diff --git a/.werks/4284 b/.werks/4284
new file mode 100644
index 0000000..165ea85
--- /dev/null
+++ b/.werks/4284
@@ -0,0 +1,11 @@
+Title: Nagios: Added missing variable MICROTIME to notification contexts
+Level: 1
+Component: notifications
+Compatible: compat
+Version: 1.4.0i4
+Date: 1485331748
+Class: fix
+
+When using the CMC, the MICROTIME context variable is always present.
+This fixes an error when using the pushover notification plugin with the
+Nagios core.
diff --git a/ChangeLog b/ChangeLog
index 7991e97..258700f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -94,6 +94,7 @@
Notifications:
* 4197 FIX: Fix sending notification to global fallback email address
+ * 4284 FIX: Nagios: Added missing variable MICROTIME to notification contexts...
BI:
* 4202 FIX: Availability now avoids pending states for times before new hosts or
services were added...
diff --git a/modules/events.py b/modules/events.py
index 1bddd32..5c617d8 100644
--- a/modules/events.py
+++ b/modules/events.py
@@ -261,6 +261,11 @@ def complete_raw_context(raw_context, with_dump, event_log):
raw_context["DATE"] = time.strftime("%Y-%m-%d", broken)
raw_context["SHORTDATETIME"] = time.strftime("%Y-%m-%d
%H:%M:%S", broken)
raw_context["LONGDATETIME"] = time.strftime("%a %b %d %H:%M:%S
%Z %Y", broken)
+ elif "MICROTIME" not in raw_context:
+ # In case the microtime is not provided, e.g. when using Nagios, then set it
here
+ # from the current time. We could look for "LONGDATETIME" and
calculate the timestamp
+ # from that one, but we try to keep this simple here.
+ raw_context["MICROTIME"] = "%d" % (time.time()*1000000)
raw_context['HOSTURL'] = '/check_mk/index.py?start_url=%s' % \
urlencode('view.py?view_name=hoststatus&host=%s'
% raw_context['HOSTNAME'])