]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon mgr osd: Add dump_osd_times interface for python
authorDavid Zafman <dzafman@redhat.com>
Fri, 10 Jan 2020 23:42:19 +0000 (23:42 +0000)
committerDavid Zafman <dzafman@redhat.com>
Thu, 27 Feb 2020 21:12:45 +0000 (13:12 -0800)
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 <dzafman@redhat.com>
src/mgr/ActivePyModules.cc
src/mon/PGMap.cc
src/mon/PGMap.h
src/osd/osd_types.cc
src/osd/osd_types.h
src/pybind/mgr/mgr_module.py
src/pybind/mgr/selftest/module.py

index 6546711aa7a041c2fb1c84e8f25debcb3861c493..cf1d5cf908796a12b11a23a2b5c176f5735ac8bd 100644 (file)
@@ -394,6 +394,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;
     cluster_state.with_osdmap_and_pgmap([&](const OSDMap& osdmap,
index 80b1a2937dda1a302d6274608dccb0092d460388..da59eac8c6843b94f55b104cf9b51eb15c7be091 100644 (file)
@@ -1609,6 +1609,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_t, pg_stat_t>& pg_stats,
index 11ba7613698602bf7af3c16615af5c1a4e592b4f..e88fdf03af058535bed138fd3f0791c30e07ff0a 100644 (file)
@@ -444,6 +444,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<pg_t>& pgs) const;
   void dump_pool_stats_full(const OSDMap &osd_map, std::stringstream *ss,
index 6151450472e0fa5ff8de3f5bca2cc7dd48472390..cc5d91d528f9a5a0234f6fdc5ca747f20701ebc4 100644 (file)
@@ -430,6 +430,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");
@@ -443,49 +449,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(ceph::buffer::list &bl, uint64_t features) const
index 3102bcb8903c34dfcb775e057fd749851f9be831..eec67724f24ab83095010f19a9b842041ca83fd2 100644 (file)
@@ -2417,6 +2417,7 @@ struct osd_stat_t {
     }
   }
   void dump(ceph::Formatter *f, bool with_net = true) const;
+  void dump_ping_time(ceph::Formatter *f) const;
   void encode(ceph::buffer::list &bl, uint64_t features) const;
   void decode(ceph::buffer::list::const_iterator &bl);
   static void generate_test_instances(std::list<osd_stat_t*>& o);
index 63e4353517bcba2a53a40e4c750f2bc57631168c..c9a6ae0f62bbf94933eb5e35dd33be480ddc9bee 100644 (file)
@@ -796,7 +796,7 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
                 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 <devid>, pg_stats,
-                pool_stats, pg_ready.
+                pool_stats, pg_ready, osd_ping_times.
 
         Note:
             All these structures have their own JSON representations: experiment
index d9c38ac1df08c361cf728c7de292cf6ab0274b47..136984bc76adb1b6187c13a8bdf4c2572d1f72ff 100644 (file)
@@ -242,6 +242,7 @@ class Module(MgrModule):
                 "pg_stats",
                 "pool_stats",
                 "osd_stats",
+                "osd_ping_times",
                 "health",
                 "mon_status",
                 "mgr_map"