]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
heap_profiler: return result via ostream
authorSage Weil <sage@inktank.com>
Thu, 16 Aug 2012 20:08:14 +0000 (13:08 -0700)
committerSage Weil <sage@inktank.com>
Thu, 16 Aug 2012 21:37:06 +0000 (14:37 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/mds/MDS.cc
src/mon/Monitor.cc
src/osd/OSD.cc
src/perfglue/disabled_heap_profiler.cc
src/perfglue/disabled_stubs.cc
src/perfglue/heap_profiler.cc
src/perfglue/heap_profiler.h

index 40cbaa780c892725ac9a0c0a40e7550a411fd872..74ef53a8d6963b05d936387a2bc3cda3147cac9c 100644 (file)
@@ -773,8 +773,11 @@ void MDS::handle_command(MMonCommand *m)
  else if (m->cmd[0] == "heap") {
    if (!ceph_using_tcmalloc())
      clog.info() << "tcmalloc not enabled, can't use heap profiler commands\n";
-   else
-     ceph_heap_profiler_handle_command(m->cmd, clog);
+   else {
+     ostringstream ss;
+     ceph_heap_profiler_handle_command(m->cmd, ss);
+     clog.info() << ss.str();
+   }
  } else dout(0) << "unrecognized command! " << m->cmd << dendl;
   m->put();
 }
index c415dbf6031c0c5ad9d78e8418483e386f6f28d2..1af46734403c260a53687a5321edb0b5b58f196a 100644 (file)
@@ -1288,8 +1288,11 @@ void Monitor::handle_command(MMonCommand *m)
       }
       if (!ceph_using_tcmalloc())
        rs = "tcmalloc not enabled, can't use heap profiler commands\n";
-      else
-       ceph_heap_profiler_handle_command(m->cmd, clog);
+      else {
+       ostringstream ss;
+       ceph_heap_profiler_handle_command(m->cmd, ss);
+       rs = ss.str();
+      }
     }
     if (m->cmd[0] == "quorum") {
       if (!access_all) {
index 06667dcbf2bb9ee4481d03659f69cc0281ea80f0..90ea5769be158e1e64545cad085d7fdf680630d2 100644 (file)
@@ -2688,7 +2688,7 @@ void OSD::do_command(Connection *con, tid_t tid, vector<string>& cmd, bufferlist
   
   else if (cmd[0] == "heap") {
     if (ceph_using_tcmalloc()) {
-      ceph_heap_profiler_handle_command(cmd, clog);
+      ceph_heap_profiler_handle_command(cmd, ss);
     } else {
       r = -EOPNOTSUPP;
       ss << "could not issue heap profiler command -- not using tcmalloc!";
index 88b9e6f30e5e60b1e1fd9a15fa2b9b957cacea5e..d2d4cb736e99df07628dd32124b35a209e195949 100644 (file)
@@ -30,4 +30,4 @@ void ceph_heap_profiler_stop() { return; }
 void ceph_heap_profiler_dump(const char *reason) { return; }
 
 void ceph_heap_profiler_handle_command(const std::vector<std::string>& cmd,
-                                       LogClient& clog) { return; }
+                                       ostream& out) { return; }
index 865a297c39fafad2b2548083a32adf439ba702f7..dfbc0e663d8a2fecbd7759ae9f6f037375ebb1a9 100644 (file)
@@ -19,7 +19,7 @@
 #include <string>
 
 void cpu_profiler_handle_command(const std::vector<std::string> &cmd,
-                                LogClient &clog)
+                                ostream& out)
 {
   out << "cpu_profiler support not linked in";
 }
index 200b503aa087dbc4712d0974e9bd0bb1ab36fe7e..550f7f924c6c32aca9b6860c8dcb31f5c64504d4 100644 (file)
@@ -86,34 +86,33 @@ void ceph_heap_profiler_dump(const char *reason)
 }
 
 void ceph_heap_profiler_handle_command(const std::vector<std::string>& cmd,
-                                       LogClient &clog)
+                                       ostream& out)
 {
   if (cmd.size() == 2 && cmd[1] == "dump") {
-    if (!ceph_heap_profiler_running())
-      clog.info() << "heap profiler not running; can't dump!\n";
-    else {
-      char *heap_stats = new char[1024];
-      ceph_heap_profiler_stats(heap_stats, 1024);
-      clog.info() << g_conf->name << "dumping heap profile now.\n"
-                 << heap_stats << std::endl;
-      ceph_heap_profiler_dump("admin request");
+    if (!ceph_heap_profiler_running()) {
+      out << "heap profiler not running; can't dump";
+      return;
     }
+    char *heap_stats = new char[1024];
+    ceph_heap_profiler_stats(heap_stats, 1024);
+    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") {
     ceph_heap_profiler_start();
-    clog.info() << g_conf->name << " started profiler \n";
+    out << g_conf->name << " started profiler";
   } else if (cmd.size() == 2 && cmd[1] == "stop_profiler") {
     ceph_heap_profiler_stop();
-    clog.info() << g_conf->name << " stopped profiler\n";
+    out << g_conf->name << " stopped profiler";
   } else if (cmd.size() == 2 && cmd[1] == "release") {
     ceph_heap_release_free_memory();
-    clog.info() << g_conf->name << " releasing free RAM back "
-                << "to system.\n";
+    out << g_conf->name << " releasing free RAM back to system.";
   } else if (cmd.size() == 2 && cmd[1] == "stats") {
     char *heap_stats = new char[1024];
     ceph_heap_profiler_stats(heap_stats, 1024);
-    clog.info() << g_conf->name << "tcmalloc heap stats:"
-               << heap_stats << std::endl;
+    out << g_conf->name << "tcmalloc heap stats:"
+       << heap_stats;
   } else {
-    clog.warn() << "unknown command " << cmd << std::endl;
+    out << "unknown command " << cmd;
   }
 }
index 98cc5b3fac1bfd3c81e9d031fa5bf13cc70aacd0..dac20d4fa31ef06cf27fa08a9453f1d2ceca3080 100644 (file)
@@ -44,6 +44,6 @@ void ceph_heap_profiler_stop();
 void ceph_heap_profiler_dump(const char *reason);
 
 void ceph_heap_profiler_handle_command(const std::vector<std::string> &cmd,
-                                       LogClient& clog);
+                                       ostream& out);
 
 #endif /* HEAP_PROFILER_H_ */