summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/top_command.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/commands/top_command.cpp')
-rw-r--r--src/mongo/db/commands/top_command.cpp90
1 files changed, 47 insertions, 43 deletions
diff --git a/src/mongo/db/commands/top_command.cpp b/src/mongo/db/commands/top_command.cpp
index 3328c286fd0..b716457f311 100644
--- a/src/mongo/db/commands/top_command.cpp
+++ b/src/mongo/db/commands/top_command.cpp
@@ -40,52 +40,56 @@
namespace {
- using namespace mongo;
+using namespace mongo;
- class TopCommand : public Command {
- public:
- TopCommand() : Command("top", true) {}
+class TopCommand : public Command {
+public:
+ TopCommand() : Command("top", true) {}
- virtual bool slaveOk() const { return true; }
- virtual bool adminOnly() const { return true; }
- virtual bool isWriteCommandForConfigServer() const { return false; }
- virtual void help(std::stringstream& help) const {
- help << "usage by collection, in micros ";
- }
- virtual void addRequiredPrivileges(const std::string& dbname,
- const BSONObj& cmdObj,
- std::vector<Privilege>* out) {
- ActionSet actions;
- actions.addAction(ActionType::top);
- out->push_back(Privilege(ResourcePattern::forClusterResource(), actions));
- }
- virtual bool run(OperationContext* txn,
- const std::string& db,
- BSONObj& cmdObj,
- int options,
- std::string& errmsg,
- BSONObjBuilder& result) {
- {
- BSONObjBuilder b( result.subobjStart( "totals" ) );
- b.append( "note", "all times in microseconds" );
- Top::get(txn->getClient()->getServiceContext()).append(b);
- b.done();
- }
- return true;
+ virtual bool slaveOk() const {
+ return true;
+ }
+ virtual bool adminOnly() const {
+ return true;
+ }
+ virtual bool isWriteCommandForConfigServer() const {
+ return false;
+ }
+ virtual void help(std::stringstream& help) const {
+ help << "usage by collection, in micros ";
+ }
+ virtual void addRequiredPrivileges(const std::string& dbname,
+ const BSONObj& cmdObj,
+ std::vector<Privilege>* out) {
+ ActionSet actions;
+ actions.addAction(ActionType::top);
+ out->push_back(Privilege(ResourcePattern::forClusterResource(), actions));
+ }
+ virtual bool run(OperationContext* txn,
+ const std::string& db,
+ BSONObj& cmdObj,
+ int options,
+ std::string& errmsg,
+ BSONObjBuilder& result) {
+ {
+ BSONObjBuilder b(result.subobjStart("totals"));
+ b.append("note", "all times in microseconds");
+ Top::get(txn->getClient()->getServiceContext()).append(b);
+ b.done();
}
+ return true;
+ }
+};
- };
-
- //
- // Command instance.
- // Registers command with the command system and make command
- // available to the client.
- //
-
- MONGO_INITIALIZER(RegisterTopCommand)(InitializerContext* context) {
+//
+// Command instance.
+// Registers command with the command system and make command
+// available to the client.
+//
- new TopCommand();
+MONGO_INITIALIZER(RegisterTopCommand)(InitializerContext* context) {
+ new TopCommand();
- return Status::OK();
- }
-} // namespace
+ return Status::OK();
+}
+} // namespace