#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"
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;
"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 " \
in_use.insert(out->begin(), out->end());
}
-
-
// =============================================================
#undef dout_context
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
+