nagios-plugin-mongodb
nagios-plugin-mongodb copied to clipboard
authentication
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
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.
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