Module: check_mk
Branch: master
Commit: 4cccd2391a66aa640d5ad620f6f7f96f5d4f7063
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4cccd2391a66aa…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 6 13:52:24 2017 +0200
4951 FIX Added missing host custom variables to notifications created by the EC
When creating notifications with the Event Console custom host attributes (HOST_*)
were not added to the notification context. In notifications created by the core
the attributes were available. This has been consolidated now, making the EC
notifications have variables like HOST_MYVAR when having a custom attribute named
MYVAR.
Change-Id: I150e38548a3de0847989b1c9b0f55d2fd2b186ba
---
.werks/4951 | 14 ++++++++++++++
bin/mkeventd | 20 +++++++++++++-------
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/.werks/4951 b/.werks/4951
new file mode 100644
index 0000000..bf9158c
--- /dev/null
+++ b/.werks/4951
@@ -0,0 +1,14 @@
+Title: Added missing host custom variables to notifications created by the EC
+Level: 1
+Component: ec
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1499341808
+Class: fix
+
+When creating notifications with the Event Console custom host attributes (HOST_*)
+were not added to the notification context. In notifications created by the core
+the attributes were available. This has been consolidated now, making the EC
+notifications have variables like HOST_MYVAR when having a custom attribute named
+MYVAR.
diff --git a/bin/mkeventd b/bin/mkeventd
index b202dbe..cec1e88 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -4121,6 +4121,11 @@ def add_infos_from_monitoring_host(context, event):
"CONTACTS" : ",".join(host_info["contacts"]),
"SERVICECONTACTGROUPNAMES" : ",".join(host_info["contact_groups"]),
})
+
+ # Add custom variables to the notification context
+ for key, val in host_info["custom_variables"].items():
+ context["HOST_%s" % key] = val
+
else:
# Host not known in active monitoring. Create articial host context
# as good as possible.
@@ -4176,13 +4181,14 @@ def find_host_in_monitoring(event_host_name):
contacts.remove("check-mk-notify")
return {
- "name" : row[0],
- "alias" : row[1],
- "address" : row[2],
- "tags" : row[3].get("TAGS", ""),
- "in_downtime" : bool(row[4]),
- "contacts" : contacts,
- "contact_groups" : row[6],
+ "name" : row[0],
+ "alias" : row[1],
+ "address" : row[2],
+ "tags" : row[3].get("TAGS", ""),
+ "custom_variables" : row[3],
+ "in_downtime" : bool(row[4]),
+ "contacts" : contacts,
+ "contact_groups" : row[6],
}