Mongostat and mongotop with PLAIN problems

Hi all

I’m having problems to use mongostat and mongotop in a sharded cluster that is integrated with an LDAP and use PLAIN authentication mechanism

I’ve already tried to type the uri in several ways and with parameters but it doesn’t work.

~ » mongostat -h 'XX.XX.XX.XX:27018' --authenticationDatabase='$external' --authenticationMechanism='PLAIN' -u 'user'
Enter password for mongo user:

2023-03-30T11:15:29.803-0600	error parsing command line options: password required for PLAIN
2023-03-30T11:15:29.803-0600	try 'mongostat --help' for more information
--------------------------------------------------------------------------------------------------------------
~ » mongostat --host='XX.XX.XX.XX' --port='27018' --authenticationDatabase='$external' --authenticationMechanism='PLAIN' -u 'user'
Enter password for mongo user:

2023-03-30T11:16:49.004-0600	error parsing command line options: password required for PLAIN
2023-03-30T11:16:49.004-0600	try 'mongostat --help' for more information
--------------------------------------------------------------------------------------------------------------
~ » mongostat --host='XX.XX.XX.XX' --port='27018' --authenticationDatabase='%24external' --authenticationMechanism='PLAIN' -u 'user'
Enter password for mongo user:

2023-03-30T11:17:10.708-0600	error parsing command line options: password required for PLAIN
2023-03-30T11:17:10.709-0600	try 'mongostat --help' for more information

--------------------------------------------------------------------------------------------------------------
~ » mongostat --uri="mongodb://user@XX.XX.XX.XX:27018/?authSource=$external&authMechanism=PLAIN"

2023-03-30T11:07:36.882-0600	error parsing command line options: error parsing uri: authSource must be non-empty when supplied in a URI
2023-03-30T11:07:36.882-0600	try 'mongostat --help' for more information
--------------------------------------------------------------------------------------------------------------
~ » mongostat --uri="mongodb://user@XX.XX.XX.XX:27018/?authSource=%24external&authMechanism=PLAIN"
Enter password for mongo user:

2023-03-30T11:09:05.529-0600	error parsing command line options: password required for PLAIN
2023-03-30T11:09:05.530-0600	try 'mongostat --help' for more information

mongotop is the same problem, I’m using ubuntu 22.04

~ » mongostat --version                                                                         1 ↵ ozky@DLMX
mongostat version: 100.6.1
git version: 6d9d341edd33b892a2ded7bae529b0e2a96aae01
Go version: go1.17.10
   os: linux
   arch: amd64
   compiler: gc
--------------------------------------------------------------------------------------------------------------
~ » mongotop --version                                                                              ozky@DLMX
mongotop version: 100.6.1
git version: 6d9d341edd33b892a2ded7bae529b0e2a96aae01
Go version: go1.17.10
   os: linux
   arch: amd64
   compiler: gc
--------------------------------------------------------------------------------------------------------------
~ » cat /etc/os-release                                                                             ozky@DLMX
PRETTY_NAME="Ubuntu 22.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.2 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Do I have the right versions?, what I’m doing wrong?

Thanks

For authenticationMechanism=PLAIN the password cannot be read interactively, it should be included in the URI as:

mongostat --uri 'mongodb://user:password@X.X.X.X:27018/?replicaSet=replset&authSource=$external&authMechanism=PLAIN'

In the command line as:

mongostat --uri 'mongodb://127.0.0.1:27018/?replicaSet=replset&authSource=$external&authMechanism=PLAIN' -u 'user' -p 'password'

Or in an external config file like:

# auth.conf
password: mypassword
mongostat --uri 'mongodb://mongoadmin@X.X.X.X:27018/?replicaSet=replset&authSource=$external&authMechanism=PLAIN' --config auth.conf

Also, note the usage of single quotes for the MongoDB URI, so the shell don’t interpret $external as a variable.

Regards!

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.