]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Extends admin console with a "heap" memory profiling command.
authorJesse Williamson <jwilliamson@suse.de>
Thu, 1 Dec 2016 20:10:04 +0000 (12:10 -0800)
committerJesse Williamson <jwilliamson@suse.de>
Fri, 31 Mar 2017 08:22:59 +0000 (01:22 -0700)
Fixes: http://tracker.ceph.com/issues/15475
Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
src/osd/OSD.cc
src/osd/OSD.h

index 4e3afa6e17415f2d1b99efa90c263757f41d8240..05bee9f4893e7448eb54429da3fbdb950d606a0c 100644 (file)
@@ -40,6 +40,7 @@
 #include "Watch.h"
 #include "osdc/Objecter.h"
 
+#include "common/errno.h"
 #include "common/ceph_argparse.h"
 #include "common/version.h"
 #include "common/io_priority.h"
@@ -1986,6 +1987,14 @@ bool OSD::asok_command(string command, cmdmap_t& cmdmap, string format,
     f->close_section();
   } else if (command == "get_latest_osdmap") {
     get_latest_osdmap();
+  } else if (command == "heap") {
+    auto result = ceph::osd_cmds::admin::heap(*cct, cmdmap, *f, ss);
+
+    // Note: Failed heap profile commands won't necessarily trigger an error:
+    f->open_object_section("result");
+    f->dump_string("error", cpp_strerror(result));
+    f->dump_bool("success", result >= 0);
+    f->close_section();
   } else if (command == "set_heap_property") {
     string property;
     int64_t value = 0;
@@ -2485,6 +2494,14 @@ void OSD::final_init()
                                     "the mon");
   assert(r == 0);
 
+  r = admin_socket->register_command( "heap",
+                                      "heap " \
+                                      "name=heapcmd,type=CephString",
+                                      asok_hook,
+                                      "show heap usage info (available only if "
+                                      "compiled with tcmalloc)");
+  assert(r == 0);
+
   r = admin_socket->register_command("set_heap_property",
                                     "set_heap_property " \
                                     "name=property,type=CephString " \
@@ -9175,8 +9192,6 @@ void OSD::PeeringWQ::_dequeue(list<PG*> *out) {
   in_use.insert(out->begin(), out->end());
 }
 
-
-
 // =============================================================
 
 #undef dout_context
@@ -9542,3 +9557,32 @@ void OSD::ShardedOpWQ::_enqueue_front(pair<spg_t, PGQueueable> item)
   sdata->sdata_cond.SignalOne();
   sdata->sdata_lock.Unlock();
 }
+
+namespace ceph { 
+namespace osd_cmds { 
+namespace admin {
+
+int heap(CephContext& cct, cmdmap_t& cmdmap, Formatter& f, std::ostream& os)
+{
+  if (!ceph_using_tcmalloc()) {
+        os << "could not issue heap profiler command -- not using tcmalloc!";
+        return -EOPNOTSUPP;
+  }
+  
+  string cmd;
+  std::vector<std::string> cmd_vec;
+  if (false == cmd_getval(&cct, cmdmap, "heapcmd", cmd)) {
+        os << "unable to get value for command \"" << cmd << "\"";
+       return -EINVAL;
+   }
+  
+  get_str_vec(cmd, cmd_vec);
+  
+  ceph_heap_profiler_handle_command(cmd_vec, os);
+  
+  return 0;
+}
+}}} // namespace ceph::osd::admin_commands
+
index 7efcd376cb4af6185a0da447f46bffafaa616702..0076526a4bd2e77a5fba4c388b7198655c728492 100644 (file)
@@ -2452,4 +2452,13 @@ extern const CompatSet::Feature ceph_osd_feature_compat[];
 extern const CompatSet::Feature ceph_osd_feature_ro_compat[];
 extern const CompatSet::Feature ceph_osd_feature_incompat[];
 
+namespace ceph { 
+namespace osd_cmds { 
+namespace admin {
+
+int heap(CephContext& cct, cmdmap_t& cmdmap, Formatter& f, std::ostream& os);
+}}} // namespace ceph::osd_cmds::admin
+
+
 #endif