Skip to content

Support for pymongo 3.x #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This plugin is a direct port of the MongoDB C plugin that will be part of collec

* Collectd 4.9 or later (for the Python plugin)
* Python 2.4 or later
* Python MongoDB driver versions 2.x and 3.x are known to work (https://github.com/mongodb/mongo-python-driver)
* Python MongoDB driver 2.4 or later (https://github.com/mongodb/mongo-python-driver)

# Configuration

Expand Down
5 changes: 3 additions & 2 deletions mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#

import collectd
from pymongo import Connection
from pymongo import MongoClient
from pymongo.read_preferences import ReadPreference
from distutils.version import StrictVersion as V


Expand Down Expand Up @@ -36,7 +37,7 @@ def submit(self, type, instance, value, db=None):
v.dispatch()

def do_server_status(self):
con = Connection(host=self.mongo_host, port=self.mongo_port, slave_okay=True)
con = MongoClient(host=self.mongo_host, port=self.mongo_port, read_preference=ReadPreference.SECONDARY)
db = con[self.mongo_db[0]]
if self.mongo_user and self.mongo_password:
db.authenticate(self.mongo_user, self.mongo_password)
Expand Down