From: David Zafman Date: Fri, 10 Jan 2020 23:42:19 +0000 (+0000) Subject: mon mgr osd: Add dump_osd_times interface for python X-Git-Tag: v14.2.10~14^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4c48ba4e4dd9f91135e86979b092c9644dba902e;p=ceph.git mon mgr osd: Add dump_osd_times interface for python The dump_osd_times interface is here for future use of a manager module. The osd_stats and pg_dump python interfaces don't return network ping information. User facing ping time information is formatted 3 decimal places Use dump_float() (low overhead) for network ping times used by python dump_osd_times and dump commands like "ceph --formet=json pg dump osds" which for now yields output like >>>> "1min": 0.61599999999999999, Signed-off-by: David Zafman (cherry picked from commit 74c2b732717ba5150e359a0462973da874f33e9e) Conflicts: src/osd/osd_types.h - omit 'ceph::' prefix in nautilus --- diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index cd334b7016c..71a6356813e 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -383,6 +383,13 @@ PyObject *ActivePyModules::get_python(const std::string &what) pg_map.dump_osd_stats(&f, false); }); return f.get(); + } else if (what == "osd_ping_times") { + cluster_state.with_pgmap( + [&f, &tstate](const PGMap &pg_map) { + PyEval_RestoreThread(tstate); + pg_map.dump_osd_ping_times(&f); + }); + return f.get(); } else if (what == "osd_pool_stats") { int64_t poolid = -ENOENT; string pool_name; diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index a56d7d99b01..947dc84effc 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -1577,6 +1577,18 @@ void PGMap::dump_osd_stats(ceph::Formatter *f, bool with_net) const f->close_section(); } +void PGMap::dump_osd_ping_times(ceph::Formatter *f) const +{ + f->open_array_section("osd_ping_times"); + for (auto& [osd, stat] : osd_stat) { + f->open_object_section("osd_ping_time"); + f->dump_int("osd", osd); + stat.dump_ping_time(f); + f->close_section(); + } + f->close_section(); +} + void PGMap::dump_pg_stats_plain( ostream& ss, const mempool::pgmap::unordered_map& pg_stats, diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index f85e3c601d2..2e3df3fa8b6 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -439,6 +439,7 @@ public: void dump_pg_stats(ceph::Formatter *f, bool brief) const; void dump_pool_stats(ceph::Formatter *f) const; void dump_osd_stats(ceph::Formatter *f, bool with_net = true) const; + void dump_osd_ping_times(ceph::Formatter *f) const; void dump_delta(ceph::Formatter *f) const; void dump_filtered_pg_stats(ceph::Formatter *f, std::set& pgs) const; void dump_pool_stats_full(const OSDMap &osd_map, std::stringstream *ss, diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 16fe5ea8cf2..baf76be1c59 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -394,6 +394,12 @@ void osd_stat_t::dump(Formatter *f, bool with_net) const ::dump(f, os_alerts); f->close_section(); if (with_net) { + dump_ping_time(f); + } +} + +void osd_stat_t::dump_ping_time(Formatter *f) const +{ f->open_array_section("network_ping_times"); for (auto &i : hb_pingtime) { f->open_object_section("entry"); @@ -407,49 +413,48 @@ void osd_stat_t::dump(Formatter *f, bool with_net) const f->open_object_section("interface"); f->dump_string("interface", "back"); f->open_object_section("average"); - f->dump_format_unquoted("1min", "%s", fixed_u_to_string(i.second.back_pingtime[0],3).c_str()); - f->dump_format_unquoted("5min", "%s", fixed_u_to_string(i.second.back_pingtime[1],3).c_str()); - f->dump_format_unquoted("15min", "%s", fixed_u_to_string(i.second.back_pingtime[2],3).c_str()); + f->dump_float("1min", i.second.back_pingtime[0]/1000.0); + f->dump_float("5min", i.second.back_pingtime[1]/1000.0); + f->dump_float("15min", i.second.back_pingtime[2]/1000.0); f->close_section(); // average f->open_object_section("min"); - f->dump_format_unquoted("1min", "%s", fixed_u_to_string(i.second.back_min[0],3).c_str()); - f->dump_format_unquoted("5min", "%s", fixed_u_to_string(i.second.back_min[1],3).c_str()); - f->dump_format_unquoted("15min", "%s", fixed_u_to_string(i.second.back_min[2],3).c_str()); + f->dump_float("1min", i.second.back_min[0]/1000.0); + f->dump_float("5min", i.second.back_min[1]/1000.0); + f->dump_float("15min", i.second.back_min[2]/1000.0); f->close_section(); // min f->open_object_section("max"); - f->dump_format_unquoted("1min", "%s", fixed_u_to_string(i.second.back_max[0],3).c_str()); - f->dump_format_unquoted("5min", "%s", fixed_u_to_string(i.second.back_max[1],3).c_str()); - f->dump_format_unquoted("15min", "%s", fixed_u_to_string(i.second.back_max[2],3).c_str()); + f->dump_float("1min", i.second.back_max[0]/1000.0); + f->dump_float("5min", i.second.back_max[1]/1000.0); + f->dump_float("15min", i.second.back_max[2]/1000.0); f->close_section(); // max - f->dump_format_unquoted("last", "%s", fixed_u_to_string(i.second.back_last,3).c_str()); + f->dump_float("last", i.second.back_last/1000.0); f->close_section(); // interface if (i.second.front_pingtime[0] != 0) { f->open_object_section("interface"); f->dump_string("interface", "front"); f->open_object_section("average"); - f->dump_format_unquoted("1min", "%s", fixed_u_to_string(i.second.front_pingtime[0],3).c_str()); - f->dump_format_unquoted("5min", "%s", fixed_u_to_string(i.second.front_pingtime[1],3).c_str()); - f->dump_format_unquoted("15min", "%s", fixed_u_to_string(i.second.front_pingtime[2],3).c_str()); + f->dump_float("1min", i.second.front_pingtime[0]/1000.0); + f->dump_float("5min", i.second.front_pingtime[1]/1000.0); + f->dump_float("15min", i.second.front_pingtime[2]/1000.0); f->close_section(); // average f->open_object_section("min"); - f->dump_format_unquoted("1min", "%s", fixed_u_to_string(i.second.front_min[0],3).c_str()); - f->dump_format_unquoted("5min", "%s", fixed_u_to_string(i.second.front_min[1],3).c_str()); - f->dump_format_unquoted("15min", "%s", fixed_u_to_string(i.second.front_min[2],3).c_str()); + f->dump_float("1min", i.second.front_min[0]/1000.0); + f->dump_float("5min", i.second.front_min[1]/1000.0); + f->dump_float("15min", i.second.front_min[2]/1000.0); f->close_section(); // min f->open_object_section("max"); - f->dump_format_unquoted("1min", "%s", fixed_u_to_string(i.second.front_max[0],3).c_str()); - f->dump_format_unquoted("5min", "%s", fixed_u_to_string(i.second.front_max[1],3).c_str()); - f->dump_format_unquoted("15min", "%s", fixed_u_to_string(i.second.front_max[2],3).c_str()); + f->dump_float("1min", i.second.front_max[0]/1000.0); + f->dump_float("5min", i.second.front_max[1]/1000.0); + f->dump_float("15min", i.second.front_max[2]/1000.0); f->close_section(); // max - f->dump_format_unquoted("last", "%s", fixed_u_to_string(i.second.front_last,3).c_str()); + f->dump_float("last", i.second.front_last/1000.0); f->close_section(); // interface } f->close_section(); // interfaces f->close_section(); // entry } f->close_section(); // network_ping_time - } } void osd_stat_t::encode(bufferlist &bl, uint64_t features) const diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 647a6eaaf63..6debfe0ea35 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2413,6 +2413,7 @@ struct osd_stat_t { } } void dump(Formatter *f, bool with_net = true) const; + void dump_ping_time(Formatter *f) const; void encode(bufferlist &bl, uint64_t features) const; void decode(bufferlist::const_iterator &bl); static void generate_test_instances(std::list& o); diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 4ca31308cb4..9b614d36751 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -702,7 +702,7 @@ class MgrModule(ceph_module.BaseMgrModule): osd_map, osd_map_tree, osd_map_crush, config, mon_map, fs_map, osd_metadata, pg_summary, io_rate, pg_dump, df, osd_stats, health, mon_status, devices, device , pg_stats, - pool_stats, pg_ready. + pool_stats, pg_ready, osd_ping_times. Note: All these structures have their own JSON representations: experiment diff --git a/src/pybind/mgr/selftest/module.py b/src/pybind/mgr/selftest/module.py index 0bbd773550b..6aff2aa578e 100644 --- a/src/pybind/mgr/selftest/module.py +++ b/src/pybind/mgr/selftest/module.py @@ -241,6 +241,7 @@ class Module(MgrModule): "pg_stats", "pool_stats", "osd_stats", + "osd_ping_times", "health", "mon_status", "mgr_map"