]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSDMonitor: add 'osd perf' command to dump recent osd perf information
authorSamuel Just <sam.just@inktank.com>
Wed, 14 Aug 2013 03:32:14 +0000 (20:32 -0700)
committerSage Weil <sage@inktank.com>
Fri, 13 Dec 2013 22:42:32 +0000 (14:42 -0800)
Signed-off-by: Samuel Just <sam.just@inktank.com>
(cherry picked from commit 94c3f29a32cbf169d896015da6765febd3c724e0)

src/Makefile.am
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/mon/PGMap.cc
src/mon/PGMap.h

index 7a816c47d659810ecdeb8381267f8a3bc2f14a22..4138cfe52c6c56a718f9acbcbd3b9adf7b51de65 100644 (file)
@@ -1615,7 +1615,8 @@ libmon_a_SOURCES = \
        mon/HealthMonitor.cc \
        mon/DataHealthService.cc \
        mon/ConfigKeyService.cc \
-       common/util.cc
+       common/util.cc \
+       common/TextTable.cc
 libmon_a_CXXFLAGS= ${AM_CXXFLAGS}
 noinst_LIBRARIES += libmon.a
 
index 89097f3b5332516f9b953f7ccfcde39cea8e35a9..39f365040008a8124c4ab175901950f17798e041 100644 (file)
@@ -325,6 +325,11 @@ COMMAND("osd getmap " \
 COMMAND("osd getcrushmap " \
        "name=epoch,type=CephInt,range=0,req=false", \
        "get CRUSH map", "osd", "r", "cli,rest")
+COMMAND("osd perf", \
+        "print dump of OSD perf summary stats", \
+        "osd", \
+        "r", \
+        "cli,rest")
 COMMAND("osd getmaxosd", "show largest OSD id", "osd", "r", "cli,rest")
 COMMAND("osd find " \
        "name=id,type=CephInt,range=0", \
index 897bbd3c2a4081bcb0709cb3dea6fc7544a613d8..3c10c42f0bd161da5a918aed238fb533a249ba46 100644 (file)
@@ -1995,7 +1995,8 @@ bool OSDMonitor::preprocess_command(MMonCommand *m)
           prefix == "osd tree" ||
           prefix == "osd ls" ||
           prefix == "osd getmap" ||
-          prefix == "osd getcrushmap") {
+          prefix == "osd getcrushmap" ||
+          prefix == "osd perf") {
     string val;
 
     epoch_t epoch = 0;
@@ -2067,6 +2068,17 @@ bool OSDMonitor::preprocess_command(MMonCommand *m)
     } else if (prefix == "osd getcrushmap") {
       p->crush->encode(rdata);
       ss << "got crush map from osdmap epoch " << p->get_epoch();
+    } else if (prefix == "osd perf") {
+      const PGMap &pgm = mon->pgmon()->pg_map;
+      if (f) {
+       f->open_object_section("osdstats");
+       pgm.dump_osd_perf_stats(f.get());
+       f->close_section();
+       f->flush(ds);
+      } else {
+       pgm.print_osd_perf_stats(&ds);
+      }
+      rdata.append(ds);
     }
     if (p != &osdmap)
       delete p;
index 1236de1115adb95e9922b212cb28c8b7380affff..90d24f62303c8dff1e72dc5fdc3a68d93865e669 100644 (file)
@@ -5,6 +5,7 @@
 
 #define dout_subsys ceph_subsys_mon
 #include "common/debug.h"
+#include "common/TextTable.h"
 #include "include/stringify.h"
 #include "common/Formatter.h"
 #include "include/ceph_features.h"
@@ -698,6 +699,40 @@ void PGMap::dump_stuck_plain(ostream& ss, PGMap::StuckPG type, utime_t cutoff) c
   dump_pg_stats_plain(ss, stuck_pg_stats);
 }
 
+void PGMap::dump_osd_perf_stats(Formatter *f) const
+{
+  f->open_array_section("osd_perf_infos");
+  for (hash_map<int32_t, osd_stat_t>::const_iterator i = osd_stat.begin();
+       i != osd_stat.end();
+       ++i) {
+    f->open_object_section("osd");
+    f->dump_int("id", i->first);
+    {
+      f->open_object_section("perf_stats");
+      i->second.fs_perf_stat.dump(f);
+      f->close_section();
+    }
+    f->close_section();
+  }
+  f->close_section();
+}
+void PGMap::print_osd_perf_stats(std::ostream *ss) const
+{
+  TextTable tab;
+  tab.define_column("osdid", TextTable::LEFT, TextTable::RIGHT);
+  tab.define_column("fs_commit_latency(ms)", TextTable::LEFT, TextTable::RIGHT);
+  tab.define_column("fs_apply_latency(ms)", TextTable::LEFT, TextTable::RIGHT);
+  for (hash_map<int32_t, osd_stat_t>::const_iterator i = osd_stat.begin();
+       i != osd_stat.end();
+       ++i) {
+    tab << i->first;
+    tab << i->second.fs_perf_stat.filestore_commit_latency;
+    tab << i->second.fs_perf_stat.filestore_apply_latency;
+    tab << TextTable::endrow;
+  }
+  (*ss) << tab;
+}
+
 void PGMap::recovery_summary(Formatter *f, ostream *out) const
 {
   bool first = true;
index e59d1b81a205cc48d044653b4442c92901d5d94d..465531335d399d0819bdb21591f2fffb8005d316 100644 (file)
@@ -168,6 +168,9 @@ public:
 
   void dump(ostream& ss) const;
 
+  void dump_osd_perf_stats(Formatter *f) const;
+  void print_osd_perf_stats(std::ostream *ss) const;
+
   void recovery_summary(Formatter *f, ostream *out) const;
   void print_summary(Formatter *f, ostream *out) const;