]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.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)
committerNathan Cutler <ncutler@suse.com>
Thu, 28 May 2020 16:38:21 +0000 (18:38 +0200)
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>
(cherry picked from commit 74c2b732717ba5150e359a0462973da874f33e9e)

Conflicts:
src/osd/osd_types.h
- omit 'ceph::' prefix in nautilus

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 cd334b7016c5b7a5c269866e3204c000c29718b3..71a6356813e8c91b9749cbb06f3b7b873136aac7 100644 (file)
@@ -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;
index a56d7d99b01014bbf92e4c462a8904da8390a590..947dc84effc3331384ad2d1e496cdc502d21db35 100644 (file)
@@ -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_t, pg_stat_t>& pg_stats,
index f85e3c601d2a3bf7cc964130fa97b2fd9c913f3d..2e3df3fa8b609472ad510adc9211d5b0cf47420e 100644 (file)
@@ -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<pg_t>& pgs) const;
   void dump_pool_stats_full(const OSDMap &osd_map, std::stringstream *ss,
index 16fe5ea8cf25b0cf6cf160a53b263e361336e8fd..baf76be1c59277a5ad69868b5151745b7741c56c 100644 (file)
@@ -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
index 647a6eaaf63744179ac5b4e33d83c422b6b5239c..6debfe0ea354d562e16995891eea06f3da9923d9 100644 (file)
@@ -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<osd_stat_t*>& o);
index 4ca31308cb4718e7346f3f3b4e977f19d06f1ba9..9b614d367519c9b001caac3acd75a843967b793d 100644 (file)
@@ -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 <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 0bbd773550b786c51407fda21af04b7a3b24fe66..6aff2aa578e95a8526f04b072045b00e7bbcc885 100644 (file)
@@ -241,6 +241,7 @@ class Module(MgrModule):
                 "pg_stats",
                 "pool_stats",
                 "osd_stats",
+                "osd_ping_times",
                 "health",
                 "mon_status",
                 "mgr_map"