Mongodb incorrect username and password

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
emartine
Posts: 660
Joined: Thu Dec 29, 2011 10:47 am

Mongodb incorrect username and password

Post 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.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Mongodb incorrect username and password

Post 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!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
emartine
Posts: 660
Joined: Thu Dec 29, 2011 10:47 am

Re: Mongodb incorrect username and password

Post 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.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Mongodb incorrect username and password

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
emartine
Posts: 660
Joined: Thu Dec 29, 2011 10:47 am

Re: Mongodb incorrect username and password

Post by emartine »

Where can I download the latest supported plugin? Maybe I have an older plugin on my nagios host.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

Re: Mongodb incorrect username and password

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
emartine
Posts: 660
Joined: Thu Dec 29, 2011 10:47 am

Re: Mongodb incorrect username and password

Post by emartine »

Same issue. Incorrect username and password.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Mongodb incorrect username and password

Post by tgriep »

I see that you opened a support ticket for this issue, shall I close this post and continue with the ticket?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
emartine
Posts: 660
Joined: Thu Dec 29, 2011 10:47 am

Re: Mongodb incorrect username and password

Post by emartine »

yes that is fine.
Locked