diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index 92028a0fc09..8cad309dc79 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -245,6 +245,7 @@ namespace mongo { help << "enable or disable performance profiling\n"; help << "{ profile : }\n"; help << "0=off 1=log slow ops 2=log all\n"; + help << "-1 to get current values\n"; help << "http://www.mongodb.org/display/DOCS/Database+Profiler"; } virtual LockType locktype() const { return WRITE; } diff --git a/shell/db.js b/shell/db.js index 652732cb6e7..791b00daa78 100644 --- a/shell/db.js +++ b/shell/db.js @@ -122,14 +122,28 @@ DB.prototype.createCollection = function(name, opt) { } /** + * @deprecated use getProfilingStatus * Returns the current profiling level of this database * @return SOMETHING_FIXME or null on error */ - DB.prototype.getProfilingLevel = function() { +DB.prototype.getProfilingLevel = function() { var res = this._dbCommand( { profile: -1 } ); return res ? res.was : null; } +/** + * @return the current profiling status + * example { was : 0, slowms : 100 } + * @return SOMETHING_FIXME or null on error + */ +DB.prototype.getProfilingStatus = function() { + var res = this._dbCommand( { profile: -1 } ); + if ( ! res.ok ) + throw "profile command failed: " + tojson( res ); + delete res.ok + return res; +} + /** Erase the entire database. (!) @@ -270,7 +284,8 @@ DB.prototype.help = function() { print("\tdb.getMongo().setSlaveOk() allow this connection to read from the nonmaster member of a replica pair"); print("\tdb.getName()"); print("\tdb.getPrevError()"); - print("\tdb.getProfilingLevel()"); + print("\tdb.getProfilingLevel() - deprecated"); + print("\tdb.getProfilingStatus() - returns if profiling is on and slow threshold "); print("\tdb.getReplicationInfo()"); print("\tdb.getSisterDB(name) get the db at the same server as this one"); print("\tdb.isMaster() check replica primary status"); diff --git a/shell/mongo_vstudio.cpp b/shell/mongo_vstudio.cpp index 59451c50b6a..636c5686598 100644 --- a/shell/mongo_vstudio.cpp +++ b/shell/mongo_vstudio.cpp @@ -1518,6 +1518,7 @@ const StringData _jscode_raw_db = "}\n" "\n" "/**\n" +"* @deprecated use getProfilingStatus\n" "* Returns the current profiling level of this database\n" "* @return SOMETHING_FIXME or null on error\n" "*/\n" @@ -1526,6 +1527,19 @@ const StringData _jscode_raw_db = "return res ? res.was : null;\n" "}\n" "\n" +"/**\n" +"* @return the current profiling status\n" +"* example { was : 0, slowms : 100 }\n" +"* @return SOMETHING_FIXME or null on error\n" +"*/\n" +"DB.prototype.getProfilingStatus = function() {\n" +"var res = this._dbCommand( { profile: -1 } );\n" +"if ( ! res.ok )\n" +"throw \"profile command failed: \" + tojson( res );\n" +"delete res.ok\n" +"return res;\n" +"}\n" +"\n" "\n" "/**\n" "Erase the entire database. (!)\n"