summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-10-15 11:20:04 -0400
committerEliot Horowitz <eliot@10gen.com>2010-10-15 11:20:04 -0400
commit069e56b8b311515492710ef3edca92ba22559143 (patch)
tree480cba6334266f94038731fc0a6fe4d8fc8046ea /tools
parentd432ea51c55faabe6c673856f6a54996fb0954ea (diff)
downloadmongo-069e56b8b311515492710ef3edca92ba22559143.tar.gz
master/slave set info in mongostat part of SERVER-1565
Diffstat (limited to 'tools')
-rw-r--r--tools/stat.cpp31
1 files changed, 30 insertions, 1 deletions
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<ServerState> 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 ){