Skip to content
Permalink
Browse files

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
  • Loading branch information
Moritz Kiemer
Moritz Kiemer committed Apr 3, 2019
1 parent d499ac1 commit 22e0ca35b184575f85b8496915e7fb3f985a2063
Showing with 23 additions and 4 deletions.
  1. +11 −0 .werks/7391
  2. +12 −4 agents/plugins/mk_mongodb
@@ -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.
@@ -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('.'))

0 comments on commit 22e0ca3

Please sign in to comment.
You can’t perform that action at this time.