From aac073dc2acbd2e7391f06136387533ea1119c07 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 18 May 2017 17:23:03 -0400 Subject: [PATCH] mon: add 'osd last-stat-seq ' command Return the latest seq for the osd reflected in the mon's digest stats. Signed-off-by: Sage Weil --- src/mon/MgrStatMonitor.h | 5 +++++ src/mon/MonCommands.h | 3 +++ src/mon/Monitor.cc | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/mon/MgrStatMonitor.h b/src/mon/MgrStatMonitor.h index 654bff0b0b6e4..4a613e8c38731 100644 --- a/src/mon/MgrStatMonitor.h +++ b/src/mon/MgrStatMonitor.h @@ -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(); diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 610564ff11de5..53531054fd0ef 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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 diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 5c3b1d8edb7cd..8a93389dac02a 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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); -- 2.39.5