Page 1 of 1

Mongodb incorrect username and password

Posted: Thu Sep 28, 2017 3:13 pm
by emartine
Question for you all:
I was running some checks for mongodb on the nagios server like this:

/usr/local/nagios/libexec/check_mongodb.py -H <serverIP> -A connect -P 27017 -W 2 -C 4 -u "<someaccount>" -p "<somepass>" -D --all-databases

I receive the error username and password incorrect. Upon further scouting for this error I read that the solution was to go on to update the schema on the mongodb server from 5 to 3 and deleting user accounts etc. Isn't this a downgrade?
I am not familiar with the mongodb server but if this is the case shouldn't the monitor be upgraded to match instead?

I need a solution to monitor these database servers.

Re: Mongodb incorrect username and password

Posted: Thu Sep 28, 2017 4:08 pm
by npolovenko
Hello, @emartine!

If you're using any special characters in your mongoDB password, you should put the whole password in single quotes:

Code: Select all

/usr/local/nagios/libexec/check_mongodb.py -H <serverIP> -A connect -P 27017 -W 2 -C 4 -u "<someaccount>" -p '<somepass>' -D --all-databases
Also, make sure that you enabled authentication on your database:
https://docs.mongodb.com/manual/tutoria ... ntication/

Let us know if this helps!

Re: Mongodb incorrect username and password

Posted: Fri Sep 29, 2017 10:43 am
by emartine
The mongodb server shows that the AuthenticationFailed due to MONGODB-CR credentials missing in the user document
I looked around the forums and found several instances of changing the authSchema version.

https://ahmedzubayr.wordpress.com/2016/ ... nagios-xi/

Recreating users on a production server is not an option.

Re: Mongodb incorrect username and password

Posted: Fri Sep 29, 2017 2:02 pm
by npolovenko
@emartine, I meant to say that you should try to create a new admin user, specifically dedicated for this plugin. This MongoDB user would be used only to run checks on databases. This could rule out any possibility for the wrong username/password.
Seems like MongoDB is no longer using the CR authentication schema, starting from version 3.0. Can you run db.version() to see what version you're running? I tested the plugin with the latest version of Mongo 3.4.9 that uses SCRAM-SHA and the plugin worked fine. It could be that the plugin is just not supporting this particular auth method.
Have you also tried running a simple command like this from the command line:

Code: Select all

mongo --port 27017 -u "yourUserName" -p "YourPassword" --authenticationDatabase "nameOfTheDB" 

Do you get any errors when you run this?

Otherwise, provided that recreating users is not an option, the only solution I could recommend is to try an alternative plugin from Nagios Exchange: https://exchange.nagios.org/directory/P ... DB/details
This one works a little different by sending a custom query to your Database. Can you see if this plugin works for you?

Re: Mongodb incorrect username and password

Posted: Fri Sep 29, 2017 4:50 pm
by emartine
Where can I download the latest supported plugin? Maybe I have an older plugin on my nagios host.

Re: Mongodb incorrect username and password

Posted: Mon Oct 02, 2017 9:45 am
by npolovenko
@emartine, You can download the latest plugins from here: http://nagios-plugins.org/ Also, you can go to admin/manage config wizards in Nagios XI, and click on check for updates. That should update your Wizards and native plugins as well.
Let us know how if that worked for you.

Re: Mongodb incorrect username and password

Posted: Tue Oct 03, 2017 2:25 pm
by emartine
Same issue. Incorrect username and password.

Re: Mongodb incorrect username and password

Posted: Tue Oct 03, 2017 4:32 pm
by tgriep
I see that you opened a support ticket for this issue, shall I close this post and continue with the ticket?

Re: Mongodb incorrect username and password

Posted: Wed Oct 04, 2017 2:26 pm
by emartine
yes that is fine.