Module: check_mk
Branch: master
Commit: a12464dbe4231ce586654b411199a00ad242ddb3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a12464dbe4231c…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Apr 4 08:02:28 2019 +0200
mk_pymongo: specifically except ConnectionFailure
Change-Id: I1b672fc523a4b78082649a1bf8ff4359a94c21c1
---
agents/plugins/mk_mongodb | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/agents/plugins/mk_mongodb b/agents/plugins/mk_mongodb
index 473e82b..78b5ada 100755
--- a/agents/plugins/mk_mongodb
+++ b/agents/plugins/mk_mongodb
@@ -34,19 +34,14 @@ def main(): # pylint: disable=too-many-branches,too-many-locals
host = None
port = None
+ con = pymongo.MongoClient(host, port,
read_preference=pymongo.ReadPreference.SECONDARY)
try:
- con = pymongo.MongoClient(host, port,
read_preference=pymongo.ReadPreference.SECONDARY)
-
- # if user and passwd:
- # db = con["admin"]
- # if not db.authenticate(user, passwd):
- # sys.exit("Username/Password incorrect")
-
+ # connecting is lazy, it might fail only now
server_status = con.admin.command("serverStatus")
- except Exception: # pylint: disable=broad-except
+ except pymongo.errors.ConnectionFailure:
sys.stdout.write("<<<mongodb_instance:sep(9)>>>\n")
sys.stdout.write("error\tInstance is down\n")
- sys.exit(0)
+ return
repl_info = server_status.get("repl")