Module: check_mk
Branch: master
Commit: 73533e25139c4d12cd43cc7364845c0be600edf1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=73533e25139c4d…
Author: Óscar Nájera <on(a)mathias-kettner.de>
Date: Fri Mar 15 11:20:12 2019 +0100
6658 FIX Differentiation of host & service problems notifications
For REST notification plugins like Slack, PagerDuty and VictorOPS. Problems
where classified by the presence of the SERVICESTATE context variable. But
in the RAW edition this variable is completed by its macro and thus the
classification leads to host problems to be described as service problems
too. Classifying after the WHAT context variable solves the issue.
Change-Id: I08aa651604c60d2810777c73746ba43ede14c2f3
---
.werks/6658 | 16 ++++++++++++++++
cmk/notification_plugins/pagerduty.py | 2 +-
cmk/notification_plugins/slack.py | 2 +-
cmk/notification_plugins/victorops.py | 2 +-
4 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/.werks/6658 b/.werks/6658
new file mode 100644
index 0000000..ac2f7b0
--- /dev/null
+++ b/.werks/6658
@@ -0,0 +1,16 @@
+Title: Differentiation of host & service problems notifications
+Level: 1
+Component: notifications
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1552646385
+
+
+For REST notification plugins like Slack, PagerDuty and VictorOPS. Problems
+where classified by the presence of the SERVICESTATE context variable. But
+in the RAW edition this variable is completed by its macro and thus the
+classification leads to host problems to be described as service problems
+too. Classifying after the WHAT context variable solves the issue.
diff --git a/cmk/notification_plugins/pagerduty.py
b/cmk/notification_plugins/pagerduty.py
index b1dfd08..80cbaed 100644
--- a/cmk/notification_plugins/pagerduty.py
+++ b/cmk/notification_plugins/pagerduty.py
@@ -71,7 +71,7 @@ def pagerduty_msg(context):
host_url, service_url = cmk_links(context)
- if context.get('SERVICESTATE', None):
+ if context.get('WHAT', None) == "SERVICE":
state = context["SERVICESTATE"]
incident_key =
'{SERVICEDESC}/{HOSTNAME}:{HOSTADDRESS}'.format(**context).replace(" ",
"")
incident = "{SERVICESTATE}: {SERVICEDESC} on
{HOSTNAME}".format(**context)
diff --git a/cmk/notification_plugins/slack.py b/cmk/notification_plugins/slack.py
index 98518aa..0b46d45 100644
--- a/cmk/notification_plugins/slack.py
+++ b/cmk/notification_plugins/slack.py
@@ -51,7 +51,7 @@ def slack_msg(context):
extend_context_with_link_urls(context, '<{}|{}>')
- if context.get('SERVICESTATE', None):
+ if context.get('WHAT', None) == "SERVICE":
color = COLORS.get(context["SERVICESTATE"])
title = "Service {NOTIFICATIONTYPE} notification".format(**context)
text = "Host: {LINKEDHOSTNAME} (IP: {HOSTADDRESS})\nService:
{LINKEDSERVICEDESC}\nState: {SERVICESTATE}".format(
diff --git a/cmk/notification_plugins/victorops.py
b/cmk/notification_plugins/victorops.py
index d50dfca..bf80d79 100644
--- a/cmk/notification_plugins/victorops.py
+++ b/cmk/notification_plugins/victorops.py
@@ -51,7 +51,7 @@ def victorops_msg(context):
extend_context_with_link_urls(context, '{0}')
- if context.get('SERVICESTATE', None):
+ if context.get('WHAT', None) == "SERVICE":
state = translate_states(context["SERVICESTATE"])
entity_id =
'{SERVICEDESC}/{HOSTNAME}:{HOSTADDRESS}'.format(**context).replace(" ",
"")
title = "{SERVICEDESC} on {HOSTNAME}".format(**context)