]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add 'osd last-stat-seq <osd>' command
authorSage Weil <sage@redhat.com>
Thu, 18 May 2017 21:23:03 +0000 (17:23 -0400)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 17:02:45 +0000 (13:02 -0400)
Return the latest seq for the osd reflected in the mon's digest stats.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/MgrStatMonitor.h
src/mon/MonCommands.h
src/mon/Monitor.cc

index 654bff0b0b6e479b2b6b9a035602d547f4ef75f4..4a613e8c3873191086653fc1474de4b07ecbb496 100644 (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();
index 610564ff11de5fabeb13225665a92ad3d1a6a7d1..53531054fd0ef8958ce2ade48fcc3710a44dce1c 100644 (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
index 5c3b1d8edb7cdf6960fe6d6ef0fbff8843eab402..8a93389dac02abeafab6a6673c391ed89f0759c2 100644 (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);