]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
OSDMonitor: add 'osd perf' command to dump recent osd perf information 500/head
authorSamuel Just <sam.just@inktank.com>
Wed, 14 Aug 2013 03:32:14 +0000 (20:32 -0700)
committerSamuel Just <sam.just@inktank.com>
Wed, 14 Aug 2013 22:31:44 +0000 (15:31 -0700)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/Makefile.am
src/mon/MonCommands.h
src/mon/OSDMonitor.cc
src/mon/PGMap.cc
src/mon/PGMap.h

index a9bbde3268601e1790a27b6b1f53785e86c26f27..f2d2bec50f63b1b096681e7c4077ae4977c4621f 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 8e9c2bb333b374a0153a34588c91c270230aaae5..e4cb9ce45ed513b45023e878234a66b674a1abe6 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 07022aec73b425878235800aeaf3bb5c72e6696a..07199ad19d3dc3728c0c5a256303a5935684d207 100644 (file)
@@ -1974,7 +1974,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;
@@ -2046,6 +2047,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 f6b88fcbfe017215d1ee9708c3c93e25061787cb..9da4bbc71d9e9dc382dc8d19ea9fe5e2c0132b3c 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;