summaryrefslogtreecommitdiff
path: root/db/dbcommands.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2009-10-07 12:43:24 -0400
committerEliot Horowitz <eliot@10gen.com>2009-10-07 12:43:24 -0400
commit498169e9e386f21e7ee83a9b900cae24dffa3d4b (patch)
treec5d0325104bf91b99be7621413a9a185fff4cc21 /db/dbcommands.cpp
parentb733978054f7b2cc2505e7a7e554d00b1f471663 (diff)
downloadmongo-498169e9e386f21e7ee83a9b900cae24dffa3d4b.tar.gz
got rid of meminfo and timeinfo and replace with serverStatus
Diffstat (limited to 'db/dbcommands.cpp')
-rw-r--r--db/dbcommands.cpp75
1 files changed, 33 insertions, 42 deletions
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp
index cc46f06f367..49290d0f66f 100644
--- a/db/dbcommands.cpp
+++ b/db/dbcommands.cpp
@@ -398,7 +398,7 @@ namespace mongo {
return repairDatabase( ns, errmsg, preserveClonedFilesOnFailure, backupOriginalFiles );
}
} cmdRepairDatabase;
-
+
/* set db profiling level
todo: how do we handle profiling information put in the db with replication?
sensibly or not?
@@ -431,61 +431,52 @@ namespace mongo {
}
} cmdProfile;
- /*
- > db.$cmd.findOne({timeinfo:1})
- {
- "totalTime" : 1.33875E8 ,
- "lockTime" : 765625.0 ,
- "ratio" : 0.005718954248366013 ,
- "ok" : 1.0
- }
- */
- class CmdTimeInfo : public Command {
+ class CmdServerStatus : public Command {
public:
virtual bool slaveOk() {
return true;
}
- CmdTimeInfo() : Command("timeinfo") {
+ CmdServerStatus() : Command("serverStatus") {
started = time(0);
}
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
- unsigned long long last, start, timeLocked;
- dbMutexInfo.timingInfo(start, timeLocked);
- last = curTimeMicros64();
- double tt = (double) last-start;
- double tl = (double) timeLocked;
- result.append("totalTime", tt);
- result.append("lockTime", tl);
- result.append("ratio", tl/tt);
- result.append("uptime",(double) (time(0)-started));
- return true;
- }
- 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;
+
+ {
+ BSONObjBuilder t;
+
+ unsigned long long last, start, timeLocked;
+ dbMutexInfo.timingInfo(start, timeLocked);
+ last = curTimeMicros64();
+ double tt = (double) last-start;
+ double tl = (double) timeLocked;
+ t.append("totalTime", tt);
+ t.append("lockTime", tl);
+ t.append("ratio", tl/tt);
+
+ result.append( "globalLock" , t.obj() );
+ }
+
+ {
+ ProcessInfo p;
+ if ( p.supported() ){
+ BSONObjBuilder t;
+ t.append( "resident" , p.getResidentSize() );
+ t.append( "virtual" , p.getVirtualMemorySize() );
+ t.append( "mapped" , MemoryMappedFile::totalMappedLength() / ( 1024 * 1024 ) );
+ result.append( "mem" , t.obj() );
+ }
+ else {
+ result.append( "mem" , "not support on this platform" );
+ }
+
}
- result << "resident" << p.getResidentSize();
- result << "virtual" << p.getVirtualMemorySize();
return true;
}
time_t started;
- } cmdMemInfo;
+ } cmdServerStatus;
/* just to check if the db has asserted */
class CmdAssertInfo : public Command {