Permalink
Browse files

got rid of meminfo and timeinfo and replace with serverStatus

  • Loading branch information...
erh committed Oct 7, 2009
1 parent b733978 commit 498169e9e386f21e7ee83a9b900cae24dffa3d4b
Showing with 47 additions and 47 deletions.
  1. +33 −42 db/dbcommands.cpp
  2. +10 −5 jstests/_runner_leak.js
  3. +4 −0 shell/db.js
View
@@ -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 {
View
@@ -6,7 +6,7 @@ var files = listFiles("jstests");
var dummyDb = db.getSisterDB( "dummyDBdummydummy" );
dummyDb.getSisterDB( "admin" ).runCommand( "closeAllDatabases" );
-prev = dummyDb.runCommand( "meminfo" );
+prev = dummyDb.serverStatus();
print( "START : " + tojson( prev ) );
@@ -26,14 +26,19 @@ files.forEach(
print(" " + Date.timeFunc( function() { load(x.name); }, 1) + "ms");
assert( dummyDb.getSisterDB( "admin" ).runCommand( "closeAllDatabases" ).ok == 1 , "closeAllDatabases failed" );
- var now = dummyDb.runCommand( "meminfo" );
- if ( now.virtual > prev.virtual )
- print( " LEAK : " + prev.virtual + " -->> " + now.virtual );
+ var now = dummyDb.serverStatus();
+ var leaked = now.mem.virtual - prev.mem.virtual;
+ if ( leaked > 0 ){
+ print( " LEAK : " + prev.mem.virtual + " -->> " + now.mem.virtual );
+ printjson( now );
+ if ( leaked > 20 )
+ throw -1;
+ }
prev = now;
}
);
dummyDb.getSisterDB( "admin" ).runCommand( "closeAllDatabases" );
-print( "END : " + tojson( dummyDb.runCommand( "meminfo" ) ) );
+print( "END : " + tojson( dummyDb.serverStatus() ) );
View
@@ -605,6 +605,10 @@ DB.prototype.serverBuildInfo = function(){
return this._adminCommand( "buildinfo" );
}
+DB.prototype.serverStatus = function(){
+ return this._adminCommand( "serverStatus" );
+}
+
DB.prototype.version = function(){
return this.serverBuildInfo().version;
}

0 comments on commit 498169e

Please sign in to comment.