diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 918db816e4c..521b33f9749 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -274,6 +274,15 @@ COMMAND_WITH_FLAG("version", "show mon daemon version", "mon", "r", "cli,rest", COMMAND("node ls " \ "name=type,type=CephChoices,strings=all|osd|mon|mds,req=false", "list all nodes in cluster [type]", "mon", "r", "cli,rest") +/* + * Monitor-specific commands under module 'mon' + */ +COMMAND_WITH_FLAG("mon compact", \ + "cause compaction of monitor's leveldb storage", \ + "mon", "rw", "cli,rest", \ + FLAG(NOFORWARD)) + + /* * MDS commands (MDSMonitor.cc) */ diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index ac1af1e5998..5b8de257466 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2692,7 +2692,9 @@ void Monitor::handle_command(MMonCommand *m) pgmon()->dispatch(m); return; } - if (module == "mon") { + if (module == "mon" && + /* 'mon compact' will be handled by the Monitor class */ + prefix != "mon compact") { monmon()->dispatch(m); return; } @@ -2737,7 +2739,7 @@ void Monitor::handle_command(MMonCommand *m) return; } - if (prefix == "compact") { + if (prefix == "compact" || prefix == "mon compact") { dout(1) << "triggering manual compaction" << dendl; utime_t start = ceph_clock_now(g_ceph_context); store->compact();