summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-11-09 00:34:47 -0500
committerEliot Horowitz <eliot@10gen.com>2010-11-09 00:34:47 -0500
commitb169ad86d9caaa89ae1ea1b015fa0702a28033b2 (patch)
tree1dd6c9a601c406bb58121b2e7ee52c90b8fa791c /tools
parent591dfb74fe2c245e66a535eeb37ac17d1e41e1fc (diff)
downloadmongo-b169ad86d9caaa89ae1ea1b015fa0702a28033b2.tar.gz
net info in mongostat SERVER-2081
Diffstat (limited to 'tools')
-rw-r--r--tools/stat.cpp33
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() );