From 069e56b8b311515492710ef3edca92ba22559143 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Fri, 15 Oct 2010 11:20:04 -0400 Subject: master/slave set info in mongostat part of SERVER-1565 --- tools/stat.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/stat.cpp b/tools/stat.cpp index 29693497568..601ec573a2c 100644 --- a/tools/stat.cpp +++ b/tools/stat.cpp @@ -191,6 +191,31 @@ namespace mongo { } _append( result , "conn" , 5 , b.getFieldDotted( "connections.current" ).numberInt() ); + if ( b["repl"].type() == Object ){ + + BSONObj x = b["repl"].embeddedObject(); + bool isReplSet = x["setName"].type() == String; + + stringstream ss; + + if ( isReplSet ){ + string setName = x["setName"].String(); + _append( result , "set" , setName.size() , setName ); + } + + if ( x["ismaster"].trueValue() ) + ss << "M"; + else if ( x["secondary"].trueValue() ) + ss << "SEC"; + else if ( isReplSet ) + ss << "UNK"; + else + ss << "SLV"; + + _append( result , "repl" , 4 , ss.str() ); + + } + { struct tm t; time_t_to_Struct( time(0), &t , true ); @@ -318,7 +343,9 @@ namespace mongo { static void serverThread( shared_ptr state ){ try { DBClientConnection conn( true ); - conn.connect( state->host ); + string errmsg; + if ( ! conn.connect( state->host , errmsg ) ) + state->error = errmsg; while ( 1 ){ try { @@ -378,6 +405,8 @@ namespace mongo { } } + sleepsecs(1); + int row = 0; while ( 1 ){ -- cgit v1.2.1