diff options
author | Brandon Diamond <brandon@10gen.com> | 2011-10-24 18:11:17 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-12-22 11:59:59 -0500 |
commit | 53bc8fe36122e83157d0840241d24b1f5d69c2ba (patch) | |
tree | 24bef9f287d12277515a6fb61a8ba2be97f73ec6 | |
parent | 5464d74491c39c22114ee61d12bbcda73994dfac (diff) | |
download | mongo-53bc8fe36122e83157d0840241d24b1f5d69c2ba.tar.gz |
SERVER-3641 SERVER-1458: mongostat uses auth with mongos/repsets
-rw-r--r-- | tools/stat.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tools/stat.cpp b/tools/stat.cpp index e1eda8db3c1..8b1b5aab786 100644 --- a/tools/stat.cpp +++ b/tools/stat.cpp @@ -365,11 +365,6 @@ namespace mongo { } int run() { - if ( !(_username.empty() || _password.empty()) && isMongos()) { - cout << "You cannot use mongostat on a mongos running with authentication enabled" << endl; - return -1; - } - _sleep = getParam( "sleep" , _sleep ); _all = hasParam( "all" ); if ( _many ) @@ -480,6 +475,9 @@ namespace mongo { string error; bool mongos; + + string username; + string password; }; static void serverThread( shared_ptr<ServerState> state ) { @@ -489,8 +487,9 @@ namespace mongo { string errmsg; if ( ! conn.connect( state->host , errmsg ) ) state->error = errmsg; - long long cycleNumber = 0; + + conn.auth("admin", state->username, state->password, errmsg); while ( ++cycleNumber ) { try { @@ -549,6 +548,9 @@ namespace mongo { state.reset( new ServerState() ); state->host = host; state->thr.reset( new boost::thread( boost::bind( serverThread , state ) ) ); + state->username = _username; + state->password = _password; + return true; } @@ -605,7 +607,7 @@ namespace mongo { int runMany() { StateMap threads; - + { string orig = getParam( "host" ); if ( orig == "" ) |