diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-02-20 09:34:25 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-02-20 09:34:25 -0500 |
commit | 3f5102bf27fd120b696c78d16668c4ba2a5f0475 (patch) | |
tree | 681380deb679a5ef108511b5c1eb067a3739c8cd /db/dbcommands.cpp | |
parent | b911ce8b250e3df57e8dd6e72cabd212972ef808 (diff) | |
download | mongo-3f5102bf27fd120b696c78d16668c4ba2a5f0475.tar.gz |
processinfo class and meminfo command, only works on darwin for the moment
Diffstat (limited to 'db/dbcommands.cpp')
-rw-r--r-- | db/dbcommands.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index 44718cf858b..85c21d25f95 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -25,6 +25,7 @@ #include "btree.h" #include "../util/lruishmap.h" #include "../util/md5.hpp" +#include "../util/processinfo.h" #include "json.h" #include "repl.h" #include "replset.h" @@ -405,6 +406,30 @@ namespace mongo { time_t started; } cmdTimeInfo; + class CmdMemInfo : public Command { + public: + virtual bool slaveOk() { + return true; + } + CmdMemInfo() : Command("meminfo") { + started = time(0); + } + bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) { + result.append("uptime",(double) (time(0)-started)); + + ProcessInfo p; + if ( ! p.supported() ){ + errmsg = "ProcessInfo not supported on this platform"; + return false; + } + + result << "resident" << p.getResidentSize(); + result << "virtual" << p.getVirtualMemorySize(); + return true; + } + time_t started; + } cmdMemInfo; + /* just to check if the db has asserted */ class CmdAssertInfo : public Command { public: |