Module: check_mk
Branch: master
Commit: b4bd8b849d68f16a2c692b837bfc1c2a70be45d6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b4bd8b849d68f1…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Wed Apr 3 15:22:52 2019 +0200
mk_mongodb: refactor II: make pylint happy
CMK-1885
Change-Id: I68b462b0a436964b90a79af75270c3e76da69a9c
---
agents/plugins/mk_mongodb | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/agents/plugins/mk_mongodb b/agents/plugins/mk_mongodb
index 2297800..35e22b2 100755
--- a/agents/plugins/mk_mongodb
+++ b/agents/plugins/mk_mongodb
@@ -18,14 +18,13 @@ import time
try:
import pymongo
-except ImportError, e:
+except ImportError:
sys.stderr.write("ERROR: Unable to import pymongo module\n")
sys.exit(2)
-def main():
- # pylint: disable=too-many-branches,unused-variable
- # TODO: might be implemented in the future..
+def main(): # pylint: disable=too-many-branches,too-many-locals
+ # might be implemented in the future..
host = None
port = None
@@ -34,7 +33,7 @@ def main():
try:
# pylint: disable=no-member
con = pymongo.database_names()
- except:
+ except Exception: # pylint: disable=broad-except
con = pymongo.MongoClient(None, None,
read_preference=pymongo.ReadPreference.SECONDARY)
con.admin.read_preference = pymongo.ReadPreference.SECONDARY
@@ -45,13 +44,11 @@ def main():
# sys.exit("Username/Password incorrect")
server_status = con.admin.command("serverStatus")
- except:
+ except Exception: # pylint: disable=broad-except
sys.stdout.write("<<<mongodb_instance:sep(9)>>>\n")
sys.stdout.write("error\tInstance is down\n")
sys.exit(0)
- server_version = tuple(con.server_info()['version'].split('.'))
-
repl_info = server_status.get("repl")
sys.stdout.write("<<<mongodb_instance:sep(9)>>>\n")
@@ -126,6 +123,7 @@ def main():
sys.stdout.write("flushed %s\n" %
server_status["backgroundFlushing"]["flushes"])
# Unused
+ # server_version = tuple(con.server_info()['version'].split('.'))
#try:
# if server_version >= tuple("2.4.0".split(".")):
# indexCounters = server_status['indexCounters']
@@ -171,7 +169,7 @@ def main():
try:
result = time.mktime(time.strptime(text, pattern))
return result
- except:
+ except Exception: # pylint: disable=broad-except
continue
year_available = False