Module: check_mk
Branch: master
Commit: 6fe88ecd7b14c53f7d36b95915788b954d08de71
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6fe88ecd7b14c5…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Fri Jan 25 09:33:14 2019 +0100
7055 FIX jolokia_generic: remove duplicate MBean in item
Werk 6901 introduced an additional word "MBean" in the item of
jolokia_generic checks. This changed the service description
to "MBean text1 MBean text2". This werk reintroduces the old
service description "MBean text1 text2".
If you have services that contain two times the word "MBean"
a service rediscovery is necessary to obtain the old format.
Change-Id: I11710413f52e2a6ce2e720377c25814a83ccff4b
---
.werks/7055 | 17 ++++++++++++++++
checks/jolokia_generic | 2 +-
.../generictests/datasets/jolokia_generic.py | 18 ++++++++---------
tests/unit/checks/test_jolokia_generic.py | 23 ++++++++++++++++++++++
4 files changed, 50 insertions(+), 10 deletions(-)
diff --git a/.werks/7055 b/.werks/7055
new file mode 100644
index 0000000..20ccb96
--- /dev/null
+++ b/.werks/7055
@@ -0,0 +1,17 @@
+Title: jolokia_generic: remove duplicate MBean in item
+Level: 1
+Component: checks
+Class: fix
+Compatible: incomp
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1548350120
+
+Werk 6901 introduced an additional word "MBean" in the item of
+jolokia_generic checks. This changed the service description
+to "MBean text1 MBean text2". This werk reintroduces the old
+service description "MBean text1 text2".
+
+If you have services that contain two times the word "MBean"
+a service rediscovery is necessary to obtain the old format.
diff --git a/checks/jolokia_generic b/checks/jolokia_generic
index 800b7c4..924c765 100644
--- a/checks/jolokia_generic
+++ b/checks/jolokia_generic
@@ -32,7 +32,7 @@ def parse_jolokia_generic(info):
instance, mbean, value, type_ = jolokia_basic_split(line, 4)
except ValueError:
continue
- item = "%s MBean %s" % (instance, mbean)
+ item = "%s %s" % (instance, mbean)
parsed[item] = {"value": value, "type": type_}
return parsed
diff --git a/tests/unit/checks/generictests/datasets/jolokia_generic.py
b/tests/unit/checks/generictests/datasets/jolokia_generic.py
index 989df71..eae344f 100644
--- a/tests/unit/checks/generictests/datasets/jolokia_generic.py
+++ b/tests/unit/checks/generictests/datasets/jolokia_generic.py
@@ -15,9 +15,9 @@ info = [
discovery = {
'': [
- ('Instance1 MBean Mitglieder_Anzahl', {}),
- ('Instance2 MBean Mitglieder Anzahl', {}),
- ('JIRA,com.atlassian.jira:type=web.requests,invocation.count MBean
jira.value', {}),
+ ('Instance1 Mitglieder_Anzahl', {}),
+ ('Instance2 Mitglieder Anzahl', {}),
+ ('JIRA,com.atlassian.jira:type=web.requests,invocation.count jira.value',
{}),
],
'rate': [],
'string': []
@@ -25,13 +25,13 @@ discovery = {
checks = {
'': [
- ('Instance1 MBean Mitglieder_Anzahl', {},
- [(0, '-23.0', [('generic_number', -23.0, None, None, None,
None)])]),
- ('Instance2 MBean Mitglieder Anzahl', {},
- [(0, '-23.0', [('generic_number', -23.0, None, None, None,
None)])]),
- ('JIRA,com.atlassian.jira:type=web.requests,invocation.count MBean
jira.name', {},
+ ('Instance1 Mitglieder_Anzahl', {}, [(0, '-23.0',
[('generic_number', -23.0, None, None,
+ None, None)])]),
+ ('Instance2 Mitglieder Anzahl', {}, [(0, '-23.0',
[('generic_number', -23.0, None, None,
+ None, None)])]),
+ ('JIRA,com.atlassian.jira:type=web.requests,invocation.count jira.name',
{},
[(3, "Non-numeric MBean value", [])]),
- ('JIRA,com.atlassian.jira:type=web.requests,invocation.count MBean
jira.value', {},
+ ('JIRA,com.atlassian.jira:type=web.requests,invocation.count jira.value',
{},
[(0, "2624460.0", [('generic_number', 2624460.0, None, None,
None, None)])]),
]
}
diff --git a/tests/unit/checks/test_jolokia_generic.py
b/tests/unit/checks/test_jolokia_generic.py
new file mode 100644
index 0000000..29c065e
--- /dev/null
+++ b/tests/unit/checks/test_jolokia_generic.py
@@ -0,0 +1,23 @@
+import pytest
+from checktestlib import assertDiscoveryResultsEqual, DiscoveryResult
+
+pytestmark = pytest.mark.checks
+
+info = [[u'PingFederate-CUK-CDI', u'TotalRequests', u'64790',
u'number'],
+ [u'PingFederate-CUK-CDI', u'MaxRequestTime', u'2649',
u'rate']]
+
+
+(a)pytest.mark.parametrize("check,info,expected_result"sult", [
+ ('jolokia_generic', info, [(u'PingFederate-CUK-CDI TotalRequests',
{})]),
+ ('jolokia_generic.rate', info, [(u'PingFederate-CUK-CDI
MaxRequestTime', {})]),
+])
+def test_jolokia_generic_discovery(check_manager, check, info, expected_result):
+ parsed = check_manager.get_check('jolokia_generic').run_parse(info)
+
+ check = check_manager.get_check(check)
+ discovered = check.run_discovery(parsed)
+ assertDiscoveryResultsEqual(
+ check,
+ DiscoveryResult(discovered),
+ DiscoveryResult(expected_result),
+ )