diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-02-28 12:35:18 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-02-28 12:35:18 -0500 |
commit | b2705cfd32d531c8efad692963ed7fc75990630a (patch) | |
tree | 2d4ddd3f2e55b1b184669124116046aa5234be68 /tools | |
parent | 30dcf4bf83f0da5f4e2d3b63d9f0ab537ec38ee7 (diff) | |
download | mongo-b2705cfd32d531c8efad692963ed7fc75990630a.tar.gz |
configurable sleep
Diffstat (limited to 'tools')
-rw-r--r-- | tools/stat.cpp | 9 | ||||
-rw-r--r-- | tools/tool.h | 5 |
2 files changed, 13 insertions, 1 deletions
diff --git a/tools/stat.cpp b/tools/stat.cpp index f568d66e785..be7b09620cd 100644 --- a/tools/stat.cpp +++ b/tools/stat.cpp @@ -37,6 +37,12 @@ namespace mongo { Stat() : Tool( "stat" , false , "admin" ){ _sleep = 1; _rowNum = 0; + + add_hidden_options() + ( "sleep" , po::value<int>() , "time to sleep between calls" ) + ; + + addPositionArg( "sleep" , 1 ); } BSONObj stats(){ @@ -113,10 +119,11 @@ namespace mongo { } int run(){ + _sleep = getParam( "sleep" , _sleep ); BSONObj prev = stats(); if ( prev.isEmpty() ) return -1; - + while ( 1 ){ sleepsecs(_sleep); BSONObj now = stats(); diff --git a/tools/tool.h b/tools/tool.h index baebdea19b2..330fc2d52e0 100644 --- a/tools/tool.h +++ b/tools/tool.h @@ -55,6 +55,11 @@ namespace mongo { return _params[name.c_str()].as<string>(); return def; } + int getParam( string name , int def ){ + if ( _params.count( name ) ) + return _params[name.c_str()].as<int>(); + return def; + } bool hasParam( string name ){ return _params.count( name ); } |