summaryrefslogtreecommitdiff
path: root/tools/stat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/stat.cpp')
-rw-r--r--tools/stat.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/tools/stat.cpp b/tools/stat.cpp
index e1eda8d..8b1b5aa 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 == "" )