Module: check_mk
Branch: master
Commit: 22e0ca35b184575f85b8496915e7fb3f985a2063
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=22e0ca35b18457…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Wed Apr 3 15:42:54 2019 +0200
7391 FIX mk_mongodb: don't crash upon missing flushing info
The plugin no longer crashes the server does not report info
on 'backgroundFlushing', as is the case for MongoDB 4.0 onwards.
CMK-1885
Change-Id: Ieda32ee6d42645e1ce06fee1c20d30141abbad4f
---
.werks/7391 | 11 +++++++++++
agents/plugins/mk_mongodb | 16 ++++++++++++----
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/.werks/7391 b/.werks/7391
new file mode 100644
index 0000000..135dd18
--- /dev/null
+++ b/.werks/7391
@@ -0,0 +1,11 @@
+Title: mk_mongodb: don't crash upon missing flushing info
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1554298869
+Class: fix
+
+The plugin no longer crashes the server does not report info
+on 'backgroundFlushing', as is the case for MongoDB 4.0 onwards.
diff --git a/agents/plugins/mk_mongodb b/agents/plugins/mk_mongodb
index a0f1f77..fc45b9a 100755
--- a/agents/plugins/mk_mongodb
+++ b/agents/plugins/mk_mongodb
@@ -18,6 +18,17 @@ import time
import pymongo # pylint: disable=import-error
+def section_flushing(server_status):
+ # key is depricated for MongoDB 4.0
+ flushing_info = server_status.get("backgroundFlushing")
+ if flushing_info is None:
+ return
+ sys.stdout.write("<<<mongodb_flushing>>>\n")
+ sys.stdout.write("average_ms %s\n" %
flushing_info["average_ms"])
+ sys.stdout.write("last_ms %s\n" % flushing_info["last_ms"])
+ sys.stdout.write("flushed %s\n" % flushing_info["flushes"])
+
+
def main(): # pylint: disable=too-many-branches,too-many-locals
# might be implemented in the future..
host = None
@@ -110,10 +121,7 @@ def main(): # pylint: disable=too-many-branches,too-many-locals
for key, value in global_lock_info[what].items():
sys.stdout.write("%s %s %s\n" % (what, key, value))
- sys.stdout.write("<<<mongodb_flushing>>>\n")
- sys.stdout.write("average_ms %s\n" %
server_status["backgroundFlushing"]["average_ms"])
- sys.stdout.write("last_ms %s\n" %
server_status["backgroundFlushing"]["last_ms"])
- sys.stdout.write("flushed %s\n" %
server_status["backgroundFlushing"]["flushes"])
+ section_flushing(server_status)
# Unused
# server_version = tuple(con.server_info()['version'].split('.'))