diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-10-25 02:14:48 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-10-25 02:14:48 -0400 |
commit | 36328b202026547bc92586c1e5572175f17c7a8f (patch) | |
tree | c8c0a639532d0272982bcc4491ad25041dadee21 /tools/stat.cpp | |
parent | 13703038d3a0575c9dfddceb86ceec78af7d4547 (diff) | |
download | mongo-36328b202026547bc92586c1e5572175f17c7a8f.tar.gz |
show memory in m or g add --all option
Diffstat (limited to 'tools/stat.cpp')
-rw-r--r-- | tools/stat.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/tools/stat.cpp b/tools/stat.cpp index c1c7eac5a7b..3498548fae2 100644 --- a/tools/stat.cpp +++ b/tools/stat.cpp @@ -49,6 +49,7 @@ namespace mongo { ("rowcount,n", po::value<int>()->default_value(0), "number of stats lines to print (0 for indefinite)") ("http", "use http instead of raw db connection") ("discover" , "discover nodes and display stats for all" ) + ("all" , "all optional fields" ) ; addPositionArg( "sleep" , 1 ); @@ -143,6 +144,17 @@ namespace mongo { width = name.size(); result.append( name , BSON( "width" << (int)width << "data" << t ) ); } + + void _appendMem( BSONObjBuilder& result , const string& name , unsigned width , double sz ){ + string unit = "m"; + if ( sz > 1024 ){ + unit = "g"; + sz /= 1024; + } + stringstream ss; + ss << setprecision(3) << sz << unit; + _append( result , name , width , ss.str() ); + } /** * BSON( <field> -> BSON( width : ### , data : XXX ) ) @@ -169,9 +181,12 @@ namespace mongo { if ( b.getFieldDotted("mem.supported").trueValue() ){ BSONObj bx = b["mem"].embeddedObject(); BSONObjIterator i( bx ); - _append( result , "mapped" , 6 , bx["mapped"].numberInt() ); - _append( result , "vsize" , 6 , bx["virtual"].numberInt() ); - _append( result , "res" , 6 , bx["resident"].numberInt() ); + _appendMem( result , "mapped" , 6 , bx["mapped"].numberInt() ); + _appendMem( result , "vsize" , 6 , bx["virtual"].numberInt() ); + _appendMem( result , "res" , 6 , bx["resident"].numberInt() ); + + if ( _all ) + _appendMem( result , "non-mapped" , 6 , bx["virtual"].numberInt() - bx["mapped"].numberInt() ); } if ( b["extra_info"].type() == Object ){ @@ -264,6 +279,7 @@ namespace mongo { int run(){ _sleep = getParam( "sleep" , _sleep ); + _all = hasParam( "all" ); if ( _many ) return runMany(); return runNormal(); @@ -497,6 +513,7 @@ namespace mongo { int _sleep; bool _http; bool _many; + bool _all; }; } |