[checkmk-commits] mk_mongodb: initially set read_preference

Moritz Kiemer mo at mathias-kettner.de
Thu Apr 4 07:30:29 CEST 2019


Module: check_mk
Branch: master
Commit: d499ac1ca52190d05e2c2cb5c9d17deeb3f1cc9f
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d499ac1ca52190d05e2c2cb5c9d17deeb3f1cc9f

Author: Moritz Kiemer <mo at mathias-kettner.de>
Date:   Wed Apr  3 15:30:55 2019 +0200

mk_mongodb: initially set read_preference

according to CMK-1885 "read_preference" becomes a read-only attribute
with version 3.0

Change-Id: Iaf5aa1a11ac7782a60245e4fc4ecf086fc3baf87

---

 agents/plugins/mk_mongodb | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/agents/plugins/mk_mongodb b/agents/plugins/mk_mongodb
index 489ba72..a0f1f77 100755
--- a/agents/plugins/mk_mongodb
+++ b/agents/plugins/mk_mongodb
@@ -24,15 +24,13 @@ def main():  # pylint: disable=too-many-branches,too-many-locals
     port = None
 
     try:
-        con = pymongo.MongoClient(host, port)
+        con = pymongo.MongoClient(host, port, read_preference=pymongo.ReadPreference.SECONDARY)
         try:
             # pylint: disable=no-member
             con = pymongo.database_names()
         except Exception:  # pylint: disable=broad-except
             con = pymongo.MongoClient(None, None, read_preference=pymongo.ReadPreference.SECONDARY)
 
-        con.admin.read_preference = pymongo.ReadPreference.SECONDARY
-
         # if user and passwd:
         #     db = con["admin"]
         #     if not db.authenticate(user, passwd):



More information about the checkmk-commits mailing list