From: Cilang Zhao Date: Tue, 5 Jan 2016 06:34:05 +0000 (+0800) Subject: tools: monstore: add 'show-versions' command. X-Git-Tag: v0.94.6~17^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=70f1ba33fe1a81d2631d54429749433a6cbfca44;p=ceph.git tools: monstore: add 'show-versions' command. Using this tool, the first/last committed version of maps will be shown. Signed-off-by: Cilang Zhao (cherry picked from commit 21e6ba0c18428caff45733e6b43d197be38af8bb) --- diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index 48b5cd3f197f9..c37c3af529359 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -201,6 +201,8 @@ void usage(const char *n, po::options_description &d) << " (default: last committed)\n" << " get crushmap [-- options] get crushmap (version VER if specified)\n" << " (default: last committed)\n" + << " show-versions [-- options] show the first&last committed version of map\n" + << " (show-versions -- --help for more info)\n" << " dump-keys dumps store keys to FILE\n" << " (default: stdout)\n" << " dump-paxos [-- options] dump paxos transactions\n" @@ -743,6 +745,38 @@ int main(int argc, char **argv) { << " version " << v << " to " << outpath << std::endl; } + } else if (cmd == "show-versions") { + string map_type; //map type:osdmap,monmap... + // visible options for this command + po::options_description op_desc("Allowed 'show-versions' options"); + op_desc.add_options() + ("help,h", "produce this help message") + ("map-type", po::value(&map_type), "map_type"); + + po::positional_options_description op_positional; + op_positional.add("map-type", 1); + + po::variables_map op_vm; + int r = parse_cmd_args(&op_desc, NULL, &op_positional, + subcmds, &op_vm); + if (r < 0) { + err = -r; + goto done; + } + + if (op_vm.count("help") || map_type.empty()) { + usage(argv[0], op_desc); + err = 0; + goto done; + } + + unsigned int v_first = 0; + unsigned int v_last = 0; + v_first = st.get(map_type, "first_committed"); + v_last = st.get(map_type, "last_committed"); + + std::cout << "first committed:\t" << v_first << "\n" + << "last committed:\t" << v_last << std::endl; } else if (cmd == "dump-paxos") { unsigned dstart = 0; unsigned dstop = ~0;