Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request for MongoDB authentication #246

Closed
riddhik84 opened this issue Aug 7, 2019 · 9 comments
Closed

Feature Request for MongoDB authentication #246

riddhik84 opened this issue Aug 7, 2019 · 9 comments
Assignees

Comments

@riddhik84
Copy link

With reference to discussion on #38

Please provide support for mongodb username and password configuration.

I am not able to plot mongodb graph without that.

I tried below settings but it does not work:

<mongodb>
	list = localhost
	max_db = 1
	<desc>
		<localhost>
			host = dbIP (not 127.0.0.1)
			port = "27017 --username=username --password=password"
			db_list = dbname
		</localhost>
	</desc>
	rigid = 0, 0, 0, 0, 0, 0, 0, 0
	limit = 100, 100, 100, 100, 100, 100, 100, 100
</mongodb>
@riddhik84
Copy link
Author

Logs:

Wed Aug  7 07:18:33 2019 - Starting Monitorix version 3.10.1 (pid 125887).
Wed Aug  7 07:18:33 2019 - Loaded main configuration file '/etc/monitorix/monitorix.conf'.
Wed Aug  7 07:18:33 2019 - Initializing graphs.
Wed Aug  7 07:18:33 2019 - fs::fs_init: Unable to detect the device name of 'swap', I/O stats won't be shown in graph. If this is really a mount point then consider using <devmap> to map it manually to a device name.
Wed Aug  7 07:18:33 2019 - fs::fs_init: Unable to detect the device name of '/boot', I/O stats won't be shown in graph. If this is really a mount point then consider using <devmap> to map it manually to a device name.
Wed Aug  7 07:18:34 2019 - Generating the 'index.html' file.
Wed Aug  7 07:18:34 2019 - WARNING: the built-in HTTP server has authentication disabled.
HTTPServer: You can connect to your server at http://localhost:8080/
Wed Aug  7 07:18:34 2019 - Started built-in HTTP server (pid 125943).
Wed Aug  7 07:18:34 2019 - Ok, ready.
exception: connect failed
exception: connect failed
exception: connect failed
exception: connect failed

@mikaku
Copy link
Owner

mikaku commented Aug 7, 2019

First of all, you might want to fix these lines:

Wed Aug  7 07:18:33 2019 - fs::fs_init: Unable to detect the device name of 'swap', I/O stats won't be shown in graph. If this is really a mount point then consider using <devmap> to map it manually to a device name.
Wed Aug  7 07:18:33 2019 - fs::fs_init: Unable to detect the device name of '/boot', I/O stats won't be shown in graph. If this is really a mount point then consider using <devmap> to map it manually to a device name.

by just removing the entries swap and /boot from your <fs> section.

Back to the MongoDB issues, make sure that the syntax you are using is correct:

mongo --host 127.0.0.1 --port 27017 --username=username --password=password --eval "printjson(db.stats(1))" dbname

If that fails, try using --username username --password password.

@riddhik84
Copy link
Author

Ok I have made changes in .conf file as you have mentioned.

<mongodb>
	list = MyMongo
	max_db = 1
	<desc>
		<MyMongo>
			host = mongoIP
			port = 27017
			username=username
			password=password 
			db_list=dbname
		</MyMongo>
	</desc>
	rigid = 0, 0, 0, 0, 0, 0, 0, 0
	limit = 100, 100, 100, 100, 100, 100, 100, 100
</mongodb>

Restarted the service. But did not see any data in MongoDB graphs. It is still empty.

The Logs are now as below:

Wed Aug  7 09:28:27 2019 - Starting Monitorix version 3.10.1 (pid 14452).
Wed Aug  7 09:28:27 2019 - Loaded main configuration file '/etc/monitorix/monitorix.conf'.
Wed Aug  7 09:28:27 2019 - Initializing graphs.
Wed Aug  7 09:28:28 2019 - Generating the 'index.html' file.
Wed Aug  7 09:28:28 2019 - WARNING: the built-in HTTP server has authentication disabled.
HTTPServer: You can connect to your server at http://localhost:8080/
Wed Aug  7 09:28:28 2019 - Started built-in HTTP server (pid 14501).
Wed Aug  7 09:28:28 2019 - Ok, ready.

@mikaku
Copy link
Owner

mikaku commented Aug 7, 2019

No, the options username and password doesn't exist yet, so don't try to use them. Use the hack with option port as I said you.

What I meant in my last post, is that you must check first the mongo command line with the same parameters that Monitorix will use to gather statistics. See the command line example in my last post.

@mikaku
Copy link
Owner

mikaku commented Aug 7, 2019

Try with the following command line:

mongo --host 127.0.0.1 --port 27017 --username=username --password=password --eval "printjson(db.stats(1))" dbname

and if the above fails:

mongo --host 127.0.0.1 --port 27017 --username username --password password --eval "printjson(db.stats(1))" dbname

That's what I meant.

@riddhik84
Copy link
Author

Ok. I got it now. I will try.

Thanks!

@riddhik84
Copy link
Author

I tried some of the combinations from command prompt and figured out that below configuration worked for me:

<mongodb>
	list = TestMongo
	max_db = 1
	<desc>
		<TestMongo>
			host = mongoip
			port = "27017 -u username -p password --authenticationDatabase admin"
			db_list = dbname
		</TestMongo>
	</desc>
	rigid = 0, 0, 0, 0, 0, 0, 0, 0
	limit = 100, 100, 100, 100, 100, 100, 100, 100
</mongodb>

I am able to see values in the graph now. :)

@mikaku
Copy link
Owner

mikaku commented Aug 7, 2019

Great!
😃

@mikaku mikaku self-assigned this Dec 4, 2019
mikaku added a commit that referenced this issue Dec 5, 2019
@mikaku
Copy link
Owner

mikaku commented Dec 5, 2019

I've not tested these new options, so let me know if you find any problem with them.

@mikaku mikaku closed this as completed Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants