From d39ff4c3d8c69c20455bf20a2cd131952ae5c17c Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 9 Nov 2013 06:06:54 -0800 Subject: [PATCH] mon/OSDMonitor: 'osd metadata N' command Report recorded metadata about an OSD. Signed-off-by: Sage Weil --- qa/workunits/cephtool/test.sh | 1 + src/mon/MonCommands.h | 4 ++++ src/mon/OSDMonitor.cc | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/qa/workunits/cephtool/test.sh b/qa/workunits/cephtool/test.sh index f0fa37893b1b5..d482ef9794bd9 100755 --- a/qa/workunits/cephtool/test.sh +++ b/qa/workunits/cephtool/test.sh @@ -212,6 +212,7 @@ for ((i=0; i < 100; i++)); do done ceph osd dump | grep 'osd.0 up' ceph osd find 1 +ceph osd metadata 1 | grep 'distro' ceph osd out 0 ceph osd dump | grep 'osd.0.*out' ceph osd in 0 diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 5a6ca6a471d26..7814a470fcdfe 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -344,6 +344,10 @@ COMMAND("osd find " \ "name=id,type=CephInt,range=0", \ "find osd in the CRUSH map and show its location", \ "osd", "r", "cli,rest") +COMMAND("osd metadata " \ + "name=id,type=CephInt,range=0", \ + "fetch metadata for osd ", \ + "osd", "r", "cli,rest") COMMAND("osd map " \ "name=pool,type=CephPoolname " \ "name=object,type=CephObjectname", \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 1967660bd1fe1..81bab3c94bf46 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2143,6 +2143,30 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) f->close_section(); f->close_section(); f->flush(rdata); + } else if (prefix == "osd metadata") { + int64_t osd; + cmd_getval(g_ceph_context, cmdmap, "id", osd); + if (!osdmap.exists(osd)) { + ss << "osd." << osd << " does not exist"; + r = -ENOENT; + goto reply; + } + string format; + cmd_getval(g_ceph_context, cmdmap, "format", format, string("json-pretty")); + boost::scoped_ptr f(new_formatter(format)); + + bufferlist bl; + mon->store->get(OSD_METADATA_PREFIX, stringify(osd), bl); + map m; + if (bl.length()) { + bufferlist::iterator p = bl.begin(); + ::decode(m, p); + } + f->open_object_section("osd_metadata"); + for (map::iterator p = m.begin(); p != m.end(); ++p) + f->dump_string(p->first.c_str(), p->second); + f->close_section(); + f->flush(rdata); } else if (prefix == "osd map") { string poolstr, objstr, namespacestr; cmd_getval(g_ceph_context, cmdmap, "pool", poolstr); -- 2.39.5