Module: check_mk
Branch: master
Commit: 987a63cdee84e4decbe3d980a5e22feba1d32c78
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=987a63cdee84e4…
Author: Óscar Nájera <on(a)mathias-kettner.de>
Date: Thu May 2 14:05:29 2019 +0200
7439 FIX PagerDuty notification when Host Check Command queries a service
PagerDuty notification plugin tried to parse perfdata and include it on the
Notification payload. This led to some buggy behavior on host problems when
using a Host check command. Since this information is not Processed by
PagerDuty only showed, we drop the perfdata information out of the
notification. Also for consistency as other notification plugins don't
include this information either.
FEED-3479
Change-Id: Iddb84b8e6b1000f9b2bfb136dbd84e54287468f7
---
.werks/7439 | 15 +++++++++++++++
cmk/notification_plugins/pagerduty.py | 14 --------------
tests/unit/cmk/notifications/test_pagerduty.py | 5 -----
3 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/.werks/7439 b/.werks/7439
new file mode 100644
index 0000000..6cd59e2
--- /dev/null
+++ b/.werks/7439
@@ -0,0 +1,15 @@
+Title: PagerDuty notification when Host Check Command queries a service
+Level: 1
+Component: notifications
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1556798474
+Class: fix
+
+PagerDuty notification plugin tried to parse perfdata and include it on the
+Notification payload. This led to some buggy behavior on host problems when
+using a Host check command. Since this information is not Processed by
+PagerDuty only showed, we drop the perfdata information out of the
+notification. Also for consistency as other notification plugins don't
+include this information either.
diff --git a/cmk/notification_plugins/pagerduty.py
b/cmk/notification_plugins/pagerduty.py
index 80cbaed..bcfad13 100644
--- a/cmk/notification_plugins/pagerduty.py
+++ b/cmk/notification_plugins/pagerduty.py
@@ -54,17 +54,6 @@ def pagerduty_severity(state):
}[state]
-def perf_values(data):
- entry = ['Value', 'warn_level', 'crit_level', 'min',
'max']
- return ",".join([e + '=' + v for e, v in zip(entry,
data.split(";")) if v])
-
-
-def construct_perfdata(data):
- data = (item.split("=") for item in data.split())
- data = {k: perf_values(v) for k, v in data}
- return data
-
-
def pagerduty_msg(context):
# type: (Dict) -> Dict
"""Build the PagerDuty incident payload"""
@@ -76,13 +65,11 @@ def pagerduty_msg(context):
incident_key =
'{SERVICEDESC}/{HOSTNAME}:{HOSTADDRESS}'.format(**context).replace(" ",
"")
incident = "{SERVICESTATE}: {SERVICEDESC} on
{HOSTNAME}".format(**context)
output = context["SERVICEOUTPUT"]
- perfdata = construct_perfdata(context["SERVICEPERFDATA"])
incident_url = service_url
else:
state = context["HOSTSTATE"]
incident_key =
'{HOSTNAME}:{HOSTADDRESS}'.format(**context).replace(" ", "")
incident = '{HOSTNAME} is {HOSTSTATE}'.format(**context)
- perfdata = construct_perfdata(context["HOSTPERFDATA"])
output = context["HOSTOUTPUT"]
incident_url = host_url
@@ -98,7 +85,6 @@ def pagerduty_msg(context):
"info": output,
"host": context.get('HOSTNAME'),
"host_address": context.get('HOSTADDRESS'),
- "perfdata": perfdata,
}
}
}
diff --git a/tests/unit/cmk/notifications/test_pagerduty.py
b/tests/unit/cmk/notifications/test_pagerduty.py
index 3cdc5c7..924ab72 100644
--- a/tests/unit/cmk/notifications/test_pagerduty.py
+++ b/tests/unit/cmk/notifications/test_pagerduty.py
@@ -31,10 +31,6 @@ from cmk.notification_plugins.pagerduty import pagerduty_msg
"host": "site1",
"host_address": "127.0.0.1",
"info": "Service Down",
- "perfdata": {
- "last_updated": "Value=20.599114",
- "new_files": "Value=0"
- }
},
"severity": "critical",
"source": "127.0.0.1",
@@ -67,7 +63,6 @@ from cmk.notification_plugins.pagerduty import pagerduty_msg
"host": "win7vm",
"host_address": "10.3.1.239",
"info": "Packet received via smart PING",
- "perfdata": {}
},
"severity": "info",
"source": "10.3.1.239",