diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/stat_util.cpp | 18 | ||||
-rw-r--r-- | tools/stat_util.h | 2 |
2 files changed, 19 insertions, 1 deletions
diff --git a/tools/stat_util.cpp b/tools/stat_util.cpp index cbf4fbfa126..38f780e8734 100644 --- a/tools/stat_util.cpp +++ b/tools/stat_util.cpp @@ -31,6 +31,18 @@ namespace mongo { } + bool StatUtil::_in( const BSONElement& me , const BSONElement& arr ) { + if ( me.type() != String || arr.type() != Array ) + return false; + + string s = me.String(); + BSONForEach(e, arr.Obj()) { + if ( e.type() == String && s == e.String() ) + return true; + } + return false; + } + BSONObj StatUtil::doRow( const BSONObj& a , const BSONObj& b ) { BSONObjBuilder result; @@ -155,7 +167,11 @@ namespace mongo { ss << "SEC"; else if ( x["isreplicaset"].trueValue() ) ss << "REC"; - else if ( isReplSet ) + else if ( x["arbiterOnly"].trueValue() ) + ss << "ARB"; + else if ( _in( x["me"] , x["passives"] ) ) + ss << "PSV"; + else if ( isReplSet ) ss << "UNK"; else ss << "SLV"; diff --git a/tools/stat_util.h b/tools/stat_util.h index c498356c266..4990e91624c 100644 --- a/tools/stat_util.h +++ b/tools/stat_util.h @@ -64,6 +64,8 @@ namespace mongo { result.append( name , BSON( "width" << (int)width << "data" << t ) ); } + bool _in( const BSONElement& me , const BSONElement& arr ); + // ------- |