[checkmk-commits] 7475 ceph_status: Adapt to new health field name 'status'

Moritz Kiemer mo at mathias-kettner.de
Mon May 6 16:00:51 CEST 2019


Module: check_mk
Branch: master
Commit: b151b324fc945e488905c72ac9440d67383db21a
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b151b324fc945e488905c72ac9440d67383db21a

Author: Moritz Kiemer <mo at mathias-kettner.de>
Date:   Mon May  6 10:07:31 2019 +0200

7475 ceph_status: Adapt to new health field name 'status'

Ceph health' JSON format has changed in luminous, which lead to a false {WARN} state
for affected devices.

Change-Id: I56646cfa19107ba286b3413ca462d9b438d6e0ec

---

 .werks/7475        | 11 +++++++++++
 checks/ceph_status | 14 +++++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/.werks/7475 b/.werks/7475
new file mode 100644
index 0000000..8535ed4
--- /dev/null
+++ b/.werks/7475
@@ -0,0 +1,11 @@
+Title: ceph_status: Adapt to new health field name 'status'
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1557129950
+Class: feature
+
+Ceph health' JSON format has changed in luminous, which lead to a false {WARN} state
+for affected devices.
diff --git a/checks/ceph_status b/checks/ceph_status
index 84a3918..9c6a000 100644
--- a/checks/ceph_status
+++ b/checks/ceph_status
@@ -28,10 +28,14 @@
 def parse_ceph_status(info):
     import json
 
-    parsed = ""
-    for line in info:
-        parsed += " ".join(line)
-    return json.loads(parsed)
+    joined_lines = [" ".join(line) for line in info]
+    parsed = json.loads(''.join(joined_lines))
+
+    # ceph health' JSON format has changed in luminous
+    if "health" in parsed and "status" not in parsed["health"]:
+        parsed["health"]["status"] = parsed["health"].get("overall_status")
+
+    return parsed
 
 
 def ceph_check_epoch(_id, epoch, params):
@@ -80,7 +84,7 @@ def check_ceph_status(_no_item, params, parsed):
         "HEALTH_ERR": (2, "error"),
     }
 
-    overall_status = parsed["health"]["overall_status"]
+    overall_status = parsed["health"]["status"]
     state, state_readable = map_health_states.get(overall_status,
                                                   (3, "unknown[%s]" % overall_status))
     yield state, 'Status: %s' % state_readable



More information about the checkmk-commits mailing list