mirror of
https://github.com/ceph/ceph
synced 2025-03-30 07:19:14 +00:00
Merge pull request #37635 from jecluis/wip-46816
mon: have 'mon stat' output json as well Reviewed-by: Jan Fajerski <jfajerski@suse.com> Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
commit
a40337c2d7
@ -1166,6 +1166,7 @@ function test_mon_mon()
|
|||||||
expect_false ceph mon feature set abcd
|
expect_false ceph mon feature set abcd
|
||||||
expect_false ceph mon feature set abcd --yes-i-really-mean-it
|
expect_false ceph mon feature set abcd --yes-i-really-mean-it
|
||||||
|
|
||||||
|
# test elector
|
||||||
expect_failure $TEMP_DIR ceph mon add disallowed_leader $first
|
expect_failure $TEMP_DIR ceph mon add disallowed_leader $first
|
||||||
ceph mon set election_strategy disallow
|
ceph mon set election_strategy disallow
|
||||||
ceph mon add disallowed_leader $first
|
ceph mon add disallowed_leader $first
|
||||||
@ -1173,6 +1174,11 @@ function test_mon_mon()
|
|||||||
ceph mon rm disallowed_leader $first
|
ceph mon rm disallowed_leader $first
|
||||||
ceph mon set election_strategy classic
|
ceph mon set election_strategy classic
|
||||||
expect_failure $TEMP_DIR ceph mon rm disallowed_leader $first
|
expect_failure $TEMP_DIR ceph mon rm disallowed_leader $first
|
||||||
|
|
||||||
|
# test mon stat
|
||||||
|
# don't check output, just ensure it does not fail.
|
||||||
|
ceph mon stat
|
||||||
|
ceph mon stat -f json | jq '.'
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_mon_priority_and_weight()
|
function test_mon_priority_and_weight()
|
||||||
|
@ -313,10 +313,29 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op)
|
|||||||
boost::scoped_ptr<Formatter> f(Formatter::create(format));
|
boost::scoped_ptr<Formatter> f(Formatter::create(format));
|
||||||
|
|
||||||
if (prefix == "mon stat") {
|
if (prefix == "mon stat") {
|
||||||
mon->monmap->print_summary(ss);
|
if (f) {
|
||||||
ss << ", election epoch " << mon->get_epoch() << ", leader "
|
f->open_object_section("monmap");
|
||||||
<< mon->get_leader() << " " << mon->get_leader_name()
|
mon->monmap->dump_summary(f.get());
|
||||||
<< ", quorum " << mon->get_quorum() << " " << mon->get_quorum_names();
|
f->dump_string("leader", mon->get_leader_name());
|
||||||
|
f->open_array_section("quorum");
|
||||||
|
for (auto rank: mon->get_quorum()) {
|
||||||
|
std::string name = mon->monmap->get_name(rank);
|
||||||
|
f->open_object_section("mon");
|
||||||
|
f->dump_int("rank", rank);
|
||||||
|
f->dump_string("name", name);
|
||||||
|
f->close_section(); // mon
|
||||||
|
}
|
||||||
|
f->close_section(); // quorum
|
||||||
|
f->close_section(); // monmap
|
||||||
|
f->flush(ss);
|
||||||
|
} else {
|
||||||
|
mon->monmap->print_summary(ss);
|
||||||
|
ss << ", election epoch " << mon->get_epoch() << ", leader "
|
||||||
|
<< mon->get_leader() << " " << mon->get_leader_name()
|
||||||
|
<< ", quorum " << mon->get_quorum()
|
||||||
|
<< " " << mon->get_quorum_names();
|
||||||
|
}
|
||||||
|
|
||||||
rdata.append(ss);
|
rdata.append(ss);
|
||||||
ss.str("");
|
ss.str("");
|
||||||
r = 0;
|
r = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user