diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-11-09 00:34:47 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-11-09 00:34:47 -0500 |
commit | b169ad86d9caaa89ae1ea1b015fa0702a28033b2 (patch) | |
tree | 1dd6c9a601c406bb58121b2e7ee52c90b8fa791c /tools | |
parent | 591dfb74fe2c245e66a535eeb37ac17d1e41e1fc (diff) | |
download | mongo-b169ad86d9caaa89ae1ea1b015fa0702a28033b2.tar.gz |
net info in mongostat SERVER-2081
Diffstat (limited to 'tools')
-rw-r--r-- | tools/stat.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/tools/stat.cpp b/tools/stat.cpp index af0a23c4856..e180fb3735b 100644 --- a/tools/stat.cpp +++ b/tools/stat.cpp @@ -155,6 +155,31 @@ namespace mongo { ss << setprecision(3) << sz << unit; _append( result , name , width , ss.str() ); } + + void _appendNet( BSONObjBuilder& result , const string& name , double diff ){ + // I think 1000 is correct for megabit, but I've seen conflicting things (ERH 11/2010) + const double div = 1000; + + string unit = "b"; + + if ( diff >= div ){ + unit = "k"; + diff /= div; + } + + if ( diff >= div ){ + unit = "m"; + diff /= div; + } + + if ( diff >= div ){ + unit = "g"; + diff /= div; + } + + string out = str::stream() << (int)diff << unit; + _append( result , name , 6 , out ); + } /** * BSON( <field> -> BSON( width : ### , data : XXX ) ) @@ -214,7 +239,13 @@ namespace mongo { temp << r << "|" << w; _append( result , "ar|aw" , 7 , temp.str() ); } - + + if ( b["network"].isABSONObj() ){ + BSONObj ax = a["network"].embeddedObject(); + BSONObj bx = b["network"].embeddedObject(); + _appendNet( result , "netIn" , diff( "bytesIn" , ax , bx ) ); + _appendNet( result , "netOut" , diff( "bytesOut" , ax , bx ) ); + } _append( result , "conn" , 5 , b.getFieldDotted( "connections.current" ).numberInt() ); |