From 882b1e987b6ca54cb67c9ad6962db068399f4413 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Mon, 5 Aug 2019 20:57:48 -0700 Subject: [PATCH] osd mon mgr: Convert all network ping time output to milliseconds To output milliseconds (usec / 1000), treat as fixed point integers Signed-off-by: David Zafman (cherry picked from commit 9d02e5d39d7b5e2806a5d98bdde24f4584e70528) Conflicts: src/mon/PGMap.cc (trivial) --- src/mgr/ClusterState.cc | 20 ++++++++++---------- src/mon/PGMap.cc | 8 ++++---- src/osd/OSD.cc | 20 ++++++++++---------- src/osd/osd_types.cc | 40 ++++++++++++++++++++-------------------- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/mgr/ClusterState.cc b/src/mgr/ClusterState.cc index f38ff04321948..5c1adccada923 100644 --- a/src/mgr/ClusterState.cc +++ b/src/mgr/ClusterState.cc @@ -340,21 +340,21 @@ bool ClusterState::asok_command(std::string_view admin_command, const cmdmap_t& f->dump_int("to osd", sitem.to); f->dump_string("interface", (sitem.back ? "back" : "front")); f->open_object_section("average"); - f->dump_unsigned("1min", sitem.times[0]); - f->dump_unsigned("5min", sitem.times[1]); - f->dump_unsigned("15min", sitem.times[2]); + f->dump_format_unquoted("1min", "%s", fixed_u_to_string(sitem.times[0],3).c_str()); + f->dump_format_unquoted("5min", "%s", fixed_u_to_string(sitem.times[1],3).c_str()); + f->dump_format_unquoted("15min", "%s", fixed_u_to_string(sitem.times[2],3).c_str()); f->close_section(); // average f->open_object_section("min"); - f->dump_unsigned("1min", sitem.min[0]); - f->dump_unsigned("5min", sitem.min[1]); - f->dump_unsigned("15min", sitem.min[2]); + f->dump_format_unquoted("1min", "%s", fixed_u_to_string(sitem.min[0],3).c_str()); + f->dump_format_unquoted("5min", "%s", fixed_u_to_string(sitem.min[1],3).c_str()); + f->dump_format_unquoted("15min", "%s", fixed_u_to_string(sitem.min[2],3).c_str()); f->close_section(); // min f->open_object_section("max"); - f->dump_unsigned("1min", sitem.max[0]); - f->dump_unsigned("5min", sitem.max[1]); - f->dump_unsigned("15min", sitem.max[2]); + f->dump_format_unquoted("1min", "%s", fixed_u_to_string(sitem.max[0],3).c_str()); + f->dump_format_unquoted("5min", "%s", fixed_u_to_string(sitem.max[1],3).c_str()); + f->dump_format_unquoted("15min", "%s", fixed_u_to_string(sitem.max[2],3).c_str()); f->close_section(); // max - f->dump_unsigned("last", sitem.last); + f->dump_format_unquoted("last", "%s", fixed_u_to_string(sitem.last,3).c_str()); f->close_section(); // entry } f->close_section(); // entries diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 177b5ec8f2e7a..f1ac5d4dc647c 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -2786,7 +2786,7 @@ void PGMap::get_health_checks( << (osdmap.is_down(sback.from) ? " (down)" : "") << " to osd." << sback.to << (osdmap.is_down(sback.to) ? " (down)" : "") - << " " << sback.pingtime << " usec" + << " " << fixed_u_to_string(sback.pingtime, 3) << " msec" << (sback.improving ? " possibly improving" : ""); detail_back.push_back(ss.str()); } @@ -2803,21 +2803,21 @@ void PGMap::get_health_checks( << (osdmap.is_down(sfront.from) ? " (down)" : "") << " to osd." << sfront.to << (osdmap.is_down(sfront.to) ? " (down)" : "") - << " " << sfront.pingtime << " usec" + << " " << fixed_u_to_string(sfront.pingtime, 3) << " msec" << (sfront.improving ? " possibly improving" : ""); detail_front.push_back(ss.str()); } if (detail_back.size() != 0) { ostringstream ss; ss << "Long heartbeat ping times on back interface seen, longest is " - << back_sorted.rbegin()->pingtime << " usec"; + << fixed_u_to_string(back_sorted.rbegin()->pingtime, 3) << " msec"; auto& d = checks->add("OSD_SLOW_PING_TIME_BACK", HEALTH_WARN, ss.str()); d.detail.swap(detail_back); } if (detail_front.size() != 0) { ostringstream ss; ss << "Long heartbeat ping times on front interface seen, longest is " - << front_sorted.rbegin()->pingtime << " usec"; + << fixed_u_to_string(front_sorted.rbegin()->pingtime, 3) << " msec"; auto& d = checks->add("OSD_SLOW_PING_TIME_FRONT", HEALTH_WARN, ss.str()); d.detail.swap(detail_front); } diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index d8d4900b65b91..237d6824b5437 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2831,21 +2831,21 @@ will start to track new ops received afterwards."; f->dump_int("to osd", sitem.to); f->dump_string("interface", (sitem.back ? "back" : "front")); f->open_object_section("average"); - f->dump_int("1min", sitem.times[0]); - f->dump_int("5min", sitem.times[1]); - f->dump_int("15min", sitem.times[2]); + f->dump_format_unquoted("1min", "%s", fixed_u_to_string(sitem.times[0],3).c_str()); + f->dump_format_unquoted("5min", "%s", fixed_u_to_string(sitem.times[1],3).c_str()); + f->dump_format_unquoted("15min", "%s", fixed_u_to_string(sitem.times[2],3).c_str()); f->close_section(); // average f->open_object_section("min"); - f->dump_int("1min", sitem.min[0]); - f->dump_int("5min", sitem.min[1]); - f->dump_int("15min", sitem.min[2]); + f->dump_format_unquoted("1min", "%s", fixed_u_to_string(sitem.max[0],3).c_str()); + f->dump_format_unquoted("5min", "%s", fixed_u_to_string(sitem.max[1],3).c_str()); + f->dump_format_unquoted("15min", "%s", fixed_u_to_string(sitem.max[2],3).c_str()); f->close_section(); // min f->open_object_section("max"); - f->dump_int("1min", sitem.max[0]); - f->dump_int("5min", sitem.max[1]); - f->dump_int("15min", sitem.max[2]); + f->dump_format_unquoted("1min", "%s", fixed_u_to_string(sitem.max[0],3).c_str()); + f->dump_format_unquoted("5min", "%s", fixed_u_to_string(sitem.max[1],3).c_str()); + f->dump_format_unquoted("15min", "%s", fixed_u_to_string(sitem.max[2],3).c_str()); f->close_section(); // max - f->dump_int("last", sitem.last); + f->dump_format_unquoted("last", "%s", fixed_u_to_string(sitem.last,3).c_str()); f->close_section(); // entry } f->close_section(); // entries diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index bd731401fbb0c..3cc0606d6e696 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -406,42 +406,42 @@ void osd_stat_t::dump(Formatter *f) const f->open_object_section("interface"); f->dump_string("interface", "back"); f->open_object_section("average"); - f->dump_int("1min", i.second.back_pingtime[0]); - f->dump_int("5min", i.second.back_pingtime[1]); - f->dump_int("15min", i.second.back_pingtime[2]); + 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->close_section(); // average f->open_object_section("min"); - f->dump_int("1min", i.second.back_min[0]); - f->dump_int("5min", i.second.back_min[1]); - f->dump_int("15min", i.second.back_min[2]); + 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->close_section(); // min f->open_object_section("max"); - f->dump_int("1min", i.second.back_max[0]); - f->dump_int("5min", i.second.back_max[1]); - f->dump_int("15min", i.second.back_max[2]); + 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->close_section(); // max - f->dump_int("last", i.second.back_last); + f->dump_format_unquoted("last", "%s", fixed_u_to_string(i.second.back_last,3).c_str()); 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_int("1min", i.second.front_pingtime[0]); - f->dump_int("5min", i.second.front_pingtime[1]); - f->dump_int("15min", i.second.front_pingtime[2]); + 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->close_section(); // average f->open_object_section("min"); - f->dump_int("1min", i.second.front_min[0]); - f->dump_int("5min", i.second.front_min[1]); - f->dump_int("15min", i.second.front_min[2]); + 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->close_section(); // min f->open_object_section("max"); - f->dump_int("1min", i.second.front_max[0]); - f->dump_int("5min", i.second.front_max[1]); - f->dump_int("15min", i.second.front_max[2]); + 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->close_section(); // max - f->dump_int("last", i.second.front_last); + f->dump_format_unquoted("last", "%s", fixed_u_to_string(i.second.front_last,3).c_str()); f->close_section(); // interface } f->close_section(); // interfaces -- 2.39.5