From b411594a6130dcfa8e97ef5e8b292aadb87d0a83 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Wed, 15 Apr 2020 16:15:32 +0300 Subject: [PATCH] bluestore/bluestore-tool: add bluefs-stats command Signed-off-by: Igor Fedotov --- src/os/bluestore/bluestore_tool.cc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index 29cdb2c06ad..092a05acb7f 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -261,7 +261,8 @@ int main(int argc, char **argv) "prime-osd-dir, " "bluefs-log-dump, " "free-dump, " - "free-score") + "free-score, " + "bluefs-stats") ; po::options_description po_all("All options"); po_all.add(po_options).add(po_positional); @@ -857,6 +858,28 @@ int main(int argc, char **argv) } bluestore.cold_close(); + } else if (action == "bluefs-stats") { + AdminSocket* admin_socket = g_ceph_context->get_admin_socket(); + ceph_assert(admin_socket); + validate_path(cct.get(), path, false); + BlueStore bluestore(cct.get(), path); + int r = bluestore.cold_open(); + if (r < 0) { + cerr << "error from cold_open: " << cpp_strerror(r) << std::endl; + exit(EXIT_FAILURE); + } + + ceph::bufferlist in, out; + ostringstream err; + r = admin_socket->execute_command( + { "{\"prefix\": \"bluefs stats\"}" }, + in, err, &out); + if (r != 0) { + cerr << "failure querying bluefs stats: " << cpp_strerror(r) << std::endl; + exit(EXIT_FAILURE); + } + cout << std::string(out.c_str(), out.length()) << std::endl; + bluestore.cold_close(); } else { cerr << "unrecognized action " << action << std::endl; return 1; -- 2.39.5