summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Eduardo Luís <joao.luis@inktank.com>2013-09-21 04:40:55 -0700
committerJoão Eduardo Luís <joao.luis@inktank.com>2013-09-21 04:40:55 -0700
commit3c64784e3fcbd0530acf14c7e3b37cae4cd54a91 (patch)
treef92c8f71914b77614b7d6bb4e535592745e16a1a
parent5cb7b2985eb0c1f87167b0a7a824225848df3bdd (diff)
parentb1eeaddd5f214c1b0883b44fc8cae07c649be7c4 (diff)
downloadceph-3c64784e3fcbd0530acf14c7e3b37cae4cd54a91.tar.gz
Merge pull request #612 from ceph/wip-6361
perfglue/heapprofiler: expect cmd name when handling command instead of 'heap <cmd>' This was broken by the cli rework. Reviewed-by: Samuel Just <sam.just@inktank.com>
-rwxr-xr-xqa/workunits/cephtool/test.sh7
-rw-r--r--src/mds/MDS.cc4
-rw-r--r--src/osd/OSD.cc4
-rw-r--r--src/perfglue/heap_profiler.cc10
4 files changed, 19 insertions, 6 deletions
diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh
index d92c2709dfd..51420a2f134 100755
--- a/qa/workunits/cephtool/test.sh
+++ b/qa/workunits/cephtool/test.sh
@@ -334,4 +334,11 @@ ceph pg set_full_ratio 95 2>$TMPFILE; check_response $? 22 'not in range'
# expect "not in range" for invalid overload percentage
ceph osd reweight-by-utilization 80 2>$TMPFILE; check_response $? 22 'not in range'
+# expect 'heap' commands to be correctly parsed
+ceph heap stats
+ceph heap start_profiler
+ceph heap dump
+ceph heap stop_profiler
+ceph heap release
+
echo OK
diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc
index fc05ca0ecb7..c2e0bbbe369 100644
--- a/src/mds/MDS.cc
+++ b/src/mds/MDS.cc
@@ -800,7 +800,9 @@ void MDS::handle_command(MMonCommand *m)
clog.info() << "tcmalloc not enabled, can't use heap profiler commands\n";
else {
ostringstream ss;
- ceph_heap_profiler_handle_command(m->cmd, ss);
+ vector<std::string> cmdargs;
+ cmdargs.insert(cmdargs.begin(), m->cmd.begin()+1, m->cmd.end());
+ ceph_heap_profiler_handle_command(cmdargs, ss);
clog.info() << ss.str();
}
} else dout(0) << "unrecognized command! " << m->cmd << dendl;
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc
index cff0c8d6a52..a9f82b51742 100644
--- a/src/osd/OSD.cc
+++ b/src/osd/OSD.cc
@@ -3948,6 +3948,10 @@ COMMAND("bench " \
"(default 1G size 4MB). Results in log.",
"osd", "rw", "cli,rest")
COMMAND("flush_pg_stats", "flush pg stats", "osd", "rw", "cli,rest")
+COMMAND("heap " \
+ "name=heapcmd,type=CephChoices,strings=dump|start_profiler|stop_profiler|release|stats", \
+ "show heap usage info (available only if compiled with tcmalloc)", \
+ "osd", "rw", "cli,rest")
COMMAND("debug_dump_missing " \
"name=filename,type=CephFilepath",
"dump missing objects to a named file", "osd", "r", "cli,rest")
diff --git a/src/perfglue/heap_profiler.cc b/src/perfglue/heap_profiler.cc
index 550f7f924c6..6b079b865fa 100644
--- a/src/perfglue/heap_profiler.cc
+++ b/src/perfglue/heap_profiler.cc
@@ -88,7 +88,7 @@ void ceph_heap_profiler_dump(const char *reason)
void ceph_heap_profiler_handle_command(const std::vector<std::string>& cmd,
ostream& out)
{
- if (cmd.size() == 2 && cmd[1] == "dump") {
+ if (cmd.size() == 1 && cmd[0] == "dump") {
if (!ceph_heap_profiler_running()) {
out << "heap profiler not running; can't dump";
return;
@@ -98,16 +98,16 @@ void ceph_heap_profiler_handle_command(const std::vector<std::string>& cmd,
out << g_conf->name << "dumping heap profile now.\n"
<< heap_stats;
ceph_heap_profiler_dump("admin request");
- } else if (cmd.size() == 2 && cmd[1] == "start_profiler") {
+ } else if (cmd.size() == 1 && cmd[0] == "start_profiler") {
ceph_heap_profiler_start();
out << g_conf->name << " started profiler";
- } else if (cmd.size() == 2 && cmd[1] == "stop_profiler") {
+ } else if (cmd.size() == 1 && cmd[0] == "stop_profiler") {
ceph_heap_profiler_stop();
out << g_conf->name << " stopped profiler";
- } else if (cmd.size() == 2 && cmd[1] == "release") {
+ } else if (cmd.size() == 1 && cmd[0] == "release") {
ceph_heap_release_free_memory();
out << g_conf->name << " releasing free RAM back to system.";
- } else if (cmd.size() == 2 && cmd[1] == "stats") {
+ } else if (cmd.size() == 1 && cmd[0] == "stats") {
char *heap_stats = new char[1024];
ceph_heap_profiler_stats(heap_stats, 1024);
out << g_conf->name << "tcmalloc heap stats:"