mon: add 'osd last-stat-seq <osd>' command

Return the latest seq for the osd reflected in the mon's digest stats.

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2017-05-18 17:23:03 -04:00
parent fa70d0e81c
commit aac073dc2a
3 changed files with 23 additions and 1 deletions

View File

@ -54,6 +54,11 @@ public:
CephContext *cct) const override;
void tick() override;
uint64_t get_last_osd_stat_seq(int osd) {
return digest.get_last_osd_stat_seq(osd);
}
void print_summary(Formatter *f, std::ostream *ss) const;
PGStatService *get_pg_stat_service();

View File

@ -133,6 +133,9 @@ COMMAND("pg set_nearfull_ratio name=ratio,type=CephFloat,range=0.0|1.0", \
COMMAND("pg map name=pgid,type=CephPgid", "show mapping of pg to osds", \
"pg", "r", "cli,rest")
COMMAND("osd last-stat-seq name=id,type=CephOsdName", \
"get the last pg stats sequence number reported for this osd", \
"osd", "r", "cli,rest")
/*
* auth commands AuthMonitor.cc

View File

@ -2958,7 +2958,8 @@ void Monitor::handle_command(MonOpRequestRef op)
mdsmon()->dispatch(op);
return;
}
if (module == "osd" || prefix == "pg map") {
if ((module == "osd" || prefix == "pg map") &&
prefix != "osd last-stat-seq") {
osdmon()->dispatch(op);
return;
}
@ -3145,6 +3146,19 @@ void Monitor::handle_command(MonOpRequestRef op)
ss2 << "report " << rdata.crc32c(CEPH_MON_PORT);
rs = ss2.str();
r = 0;
} else if (prefix == "osd last-stat-seq") {
int64_t osd;
cmd_getval(g_ceph_context, cmdmap, "id", osd);
uint64_t seq = mgrstatmon()->get_last_osd_stat_seq(osd);
if (f) {
f->dump_unsigned("seq", seq);
f->flush(ds);
} else {
ds << seq;
rdata.append(ds);
}
rs = "";
r = 0;
} else if (prefix == "node ls") {
string node_type("all");
cmd_getval(g_ceph_context, cmdmap, "type", node_type);