From 3b95e5be69c199a2a195c57aba12d88c242225ac Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2019 19:57:35 +0200 Subject: Adding upstream version 1.14.0~rc0. Signed-off-by: Daniel Baumann --- collectors/python.d.plugin/mongodb/README.md | 1 + collectors/python.d.plugin/mongodb/mongodb.chart.py | 5 +++-- collectors/python.d.plugin/mongodb/mongodb.conf | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'collectors/python.d.plugin/mongodb') diff --git a/collectors/python.d.plugin/mongodb/README.md b/collectors/python.d.plugin/mongodb/README.md index ac8930dd2..3ddf137d7 100644 --- a/collectors/python.d.plugin/mongodb/README.md +++ b/collectors/python.d.plugin/mongodb/README.md @@ -156,6 +156,7 @@ Sample: ```yaml local: name : 'local' + authdb: 'admin' host : '127.0.0.1' port : 27017 user : 'netdata' diff --git a/collectors/python.d.plugin/mongodb/mongodb.chart.py b/collectors/python.d.plugin/mongodb/mongodb.chart.py index 92740ff86..ee32593c2 100644 --- a/collectors/python.d.plugin/mongodb/mongodb.chart.py +++ b/collectors/python.d.plugin/mongodb/mongodb.chart.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Description: mongodb netdata python.d module -# Author: l2isbad +# Author: ilyam8 # SPDX-License-Identifier: GPL-3.0-or-later from copy import deepcopy @@ -424,6 +424,7 @@ class Service(SimpleService): SimpleService.__init__(self, configuration=configuration, name=name) self.order = ORDER[:] self.definitions = deepcopy(CHARTS) + self.authdb = self.configuration.get('authdb', 'admin') self.user = self.configuration.get('user') self.password = self.configuration.get('pass') self.host = self.configuration.get('host', '127.0.0.1') @@ -707,7 +708,7 @@ class Service(SimpleService): try: connection = MongoClient(**conn_vars) if self.user and self.password: - connection.admin.authenticate(name=self.user, password=self.password) + getattr(connection, self.authdb).authenticate(name=self.user, password=self.password) # elif self.user: # connection.admin.authenticate(name=self.user, mechanism='MONGODB-X509') server_status = connection.admin.command('serverStatus') diff --git a/collectors/python.d.plugin/mongodb/mongodb.conf b/collectors/python.d.plugin/mongodb/mongodb.conf index f69acac79..53858ae2e 100644 --- a/collectors/python.d.plugin/mongodb/mongodb.conf +++ b/collectors/python.d.plugin/mongodb/mongodb.conf @@ -66,6 +66,8 @@ # # in all cases, the following can also be set: # +# authdb: 'dbname' # database to authenticate the user against, +# # defaults to "admin". # user: 'username' # the mongodb username to use # pass: 'password' # the mongodb password to use # @@ -80,3 +82,11 @@ local: name : 'local' host : '127.0.0.1' port : 27017 + +# authsample: +# name : 'secure' +# host : 'mongodb.example.com' +# port : 27017 +# authdb : 'admin' +# user : 'monitor' +# password : 'supersecret' -- cgit v1.2.3