Module: check_mk
Branch: master
Commit: 29e934d0fe9edc0cfb4510faa1d5ee55d1aef2fa
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=29e934d0fe9edc…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Apr 4 08:44:47 2019 +0200
mk_mongodb: factor out piggybacked sections
Change-Id: Ifb85226fd8d30cf567b9e6987c4c7acdf8fe7a75
---
agents/plugins/mk_mongodb | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/agents/plugins/mk_mongodb b/agents/plugins/mk_mongodb
index ad88514..43351de 100755
--- a/agents/plugins/mk_mongodb
+++ b/agents/plugins/mk_mongodb
@@ -47,7 +47,7 @@ def section_flushing(server_status):
sys.stdout.write("flushed %s\n" % flushing_info["flushes"])
-def main(): # pylint: disable=too-many-branches,too-many-locals
+def main():
# might be implemented in the future..
host = None
port = None
@@ -64,10 +64,20 @@ def main(): # pylint: disable=too-many-branches,too-many-locals
section_instance(server_status)
repl_info = server_status.get("repl")
+
+ if repl_info and not repl_info.get("ismaster"):
+ return
+
if repl_info:
- if not repl_info.get("ismaster"):
- sys.exit(0)
sys.stdout.write("<<<<%s>>>>\n" %
repl_info["setName"])
+ potentially_piggybacked_sections(con, server_status, repl_info)
+ if repl_info:
+ sys.stdout.write("<<<<>>>>\n")
+
+
+def potentially_piggybacked_sections(con, server_status, repl_info):
+ # pylint: disable=too-many-branches,too-many-locals
+ if repl_info:
sys.stdout.write("<<<mongodb_replica:sep(9)>>>\n")
sys.stdout.write("primary\t%s\n" % repl_info.get("primary"))
sys.stdout.write("hosts\t%s\n" % "
".join(repl_info.get("hosts")))
@@ -198,8 +208,6 @@ def main(): # pylint: disable=too-many-branches,too-many-locals
file(state_file,
"w").write("%d" %
get_timestamp(startup_warnings["log"][-1].split(".")[0]))
- sys.stdout.write("<<<<>>>>\n")
-
if __name__ == "__main__":
sys.exit(main())