nagios-plugin-mongodb icon indicating copy to clipboard operation
nagios-plugin-mongodb copied to clipboard

authentication

Open avittecoq opened this issue 12 years ago • 2 comments

when running:

python check_mongodb.py -A replica_primary -u nagios -p password -r replset

on an auth enabled instance

result:

pymongo.errors.OperationFailure: database error: not authorized for query on nagios.system.namespaces

because on line 1147:

db = con["nagios"]

switch to nagios db without authenticating first on it. so it fails

a workaround is to add:

            db = con["nagios"]
            if not db.authenticate(user, passwd):
                sys.exit("Username/Password incorrect")

after line 271

avittecoq avatar Oct 30 '13 11:10 avittecoq

I'm wrestling with this, too. I currently have the nagios user defined in the admin db, with the following roles:

roles: [ 'readAnyDatabase', 'clusterAdmin' ], otherDBRoles: { nagios: [ 'readWrite' ] },

The necessary permissions should be documented on this site somewhere :-)

However, I've now got another issue, which I'll be making a separate ticket for: it tries to write in the local database, too.

meersjo avatar Jan 13 '14 17:01 meersjo

Note that the clusterAdmin above should be changed to clusterMonitor in order to grant read-only access, as read-write is not required. See : https://docs.mongodb.org/manual/reference/built-in-roles/#cluster-administration-roles

thias avatar Nov 11 '15 12:11 thias