Module: check_mk
Branch: master
Commit: f87ec40b55e27472ce02d10bdb252f9be419e021
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f87ec40b55e274…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Dec 20 09:23:21 2018 +0100
6950 FIX db2_connections: Fix crash upon decimal comma
Change-Id: I21b73ff2bf9daefedab3bc4ed4133a1233ea17b9
---
.werks/6950 | 9 +++++
checks/db2_connections | 6 +++-
.../generictests/datasets/db2_connections.py | 39 ++++++++++++++++++++++
3 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/.werks/6950 b/.werks/6950
new file mode 100644
index 0000000..ba1d481
--- /dev/null
+++ b/.werks/6950
@@ -0,0 +1,9 @@
+Title: db2_connections: Fix crash upon decimal comma
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1545294137
+Class: fix
+
diff --git a/checks/db2_connections b/checks/db2_connections
index d92dc8d..691109f 100644
--- a/checks/db2_connections
+++ b/checks/db2_connections
@@ -64,7 +64,11 @@ def check_db2_connections(item, params, parsed):
ms = int(latency)
else: # handle old time format: 'min:seconds.milliseconds'
minutes, rest = data["latency"].split(":")
- seconds, mseconds = rest.split(".")
+ # handle different locale settings
+ if ',' in rest:
+ seconds, mseconds = rest.split(",")
+ else:
+ seconds, mseconds = rest.split(".")
ms = int(minutes) * 60 * 1000 + int(seconds) * 1000 + int(mseconds)
yield 0, "Latency: %.2f ms" % ms, [("latency", ms)]
diff --git a/tests/unit/checks/generictests/datasets/db2_connections.py
b/tests/unit/checks/generictests/datasets/db2_connections.py
new file mode 100644
index 0000000..d1eee87
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/db2_connections.py
@@ -0,0 +1,39 @@
+
+
+checkname = 'db2_connections'
+
+
+info = [
+ ['[[[db2taddm:CMDBS1]]]'],
+ ['port', '50214'],
+ ['connections', '40'],
+ ['latency', '0:1.03'],
+ ['[[[db2taddm:CMDBS1de]]]'],
+ ['port', '50213'],
+ ['connections', '42'],
+ ['latency', '0:1,03'],
+]
+
+
+discovery = {
+ '': [
+ ('db2taddm:CMDBS1', None),
+ ('db2taddm:CMDBS1de', None),
+ ],
+}
+
+
+checks = {
+ '': [
+ ('db2taddm:CMDBS1', {'levels_total': (150, 200)}, [
+ (0, 'Connections: 40', [('connections', 40, 150, 200, None,
None)]),
+ (0, 'Port: 50214', []),
+ (0, 'Latency: 1003.00 ms', [('latency', 1003, None, None,
None, None)]),
+ ]),
+ ('db2taddm:CMDBS1de', {'levels_total': (150, 200)}, [
+ (0, 'Connections: 42', [('connections', 42, 150, 200, None,
None)]),
+ (0, 'Port: 50213', []),
+ (0, 'Latency: 1003.00 ms', [('latency', 1003, None, None,
None, None)]),
+ ]),
+ ],
+}