From 455f28a78ee22b6a535831ff70a330fa1379567c Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 13 Aug 2013 20:32:14 -0700 Subject: [PATCH] OSDMonitor: add 'osd perf' command to dump recent osd perf information Signed-off-by: Samuel Just (cherry picked from commit 94c3f29a32cbf169d896015da6765febd3c724e0) --- src/Makefile.am | 3 ++- src/mon/MonCommands.h | 5 +++++ src/mon/OSDMonitor.cc | 14 +++++++++++++- src/mon/PGMap.cc | 35 +++++++++++++++++++++++++++++++++++ src/mon/PGMap.h | 3 +++ 5 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 7a816c47d6598..4138cfe52c6c5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 89097f3b53325..39f365040008a 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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", \ diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 897bbd3c2a408..3c10c42f0bd16 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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; diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 1236de1115adb..90d24f62303c8 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -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::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::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; diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index e59d1b81a205c..465531335d399 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -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; -- 2.39.5