MeetMe/newrelic-plugin-agent — pull request #136 by stevendgonzales (2013-08-28 02:09:08+00:00)
Title: correct error in mongodb plugin when using authentication

Fixes an error when using MongoDB with authentication.

https://github.com/MeetMe/newrelic-plugin-agent/blob/master/newrelic_plugin_agent/plugins/mongodb.py#L225-L234

Line 231:
```client.db.authenticate(self.config['admin_username'],```

When using PyMongo 2.6 this line is actually trying to use the PyMongo MongoClient authenticate against a database named "db"
This will throw an authentication error unless there is a user registered.
This is because MongoClient overrides the __getattr__ method to return the specified database:

https://github.com/mongodb/mongo-python-driver/blob/master/pymongo/mongo_client.py#L1134-L1143

In order for the plugin to use the admin user specified the client should be authenticating against the "admin" database using:

client.admin.authenticate(self.config['admin_username'],