]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: transmit perf counter prio to the mgr
authorJohn Spray <john.spray@redhat.com>
Fri, 1 Sep 2017 16:00:59 +0000 (12:00 -0400)
committerJohn Spray <john.spray@redhat.com>
Wed, 1 Nov 2017 23:03:24 +0000 (23:03 +0000)
Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit f304f84cfbc22c1a54d152cc38227077bc564a7e)

src/messages/MMgrReport.h
src/mgr/MgrClient.cc
src/mgr/PyModules.cc

index 9b033ec23c23645bf7bf474635a99fa6e93da662..26268927b1a5c99d44e6d02b3170039978dea5f7 100644 (file)
@@ -29,27 +29,36 @@ public:
   std::string nick;
   enum perfcounter_type_d type;
 
+  // For older clients that did not send priority, pretend everything
+  // is "useful" so that mgr plugins filtering on prio will get some
+  // data (albeit probably more than they wanted)
+  uint8_t priority = PerfCountersBuilder::PRIO_USEFUL;
+
   void encode(bufferlist &bl) const
   {
     // TODO: decide whether to drop the per-type
     // encoding here, we could rely on the MgrReport
     // verisoning instead.
-    ENCODE_START(1, 1, bl);
+    ENCODE_START(2, 1, bl);
     ::encode(path, bl);
     ::encode(description, bl);
     ::encode(nick, bl);
     static_assert(sizeof(type) == 1, "perfcounter_type_d must be one byte");
     ::encode((uint8_t)type, bl);
+    ::encode(priority, bl);
     ENCODE_FINISH(bl);
   }
   
   void decode(bufferlist::iterator &p)
   {
-    DECODE_START(1, p);
+    DECODE_START(2, p);
     ::decode(path, p);
     ::decode(description, p);
     ::decode(nick, p);
     ::decode((uint8_t&)type, p);
+    if (struct_v >= 2) {
+      ::decode(priority, p);
+    }
     DECODE_FINISH(p);
   }
 };
index 401edf1b0f1f890ded7a98c3bdee885727f530f5..dd35e27141720a2861c49b181f470b7259b2cb5e 100644 (file)
@@ -262,6 +262,7 @@ void MgrClient::send_report()
          type.nick = data.nick;
        }
        type.type = data.type;
+        type.priority = data.prio;
        report->declare_types.push_back(std::move(type));
        session->declared.insert(path);
       }
index fb1ce7400459d0cf651b90ec77de4bbfe00e9893..e7abcb3a3adf2d39879ba6b7f276eecf22243845 100644 (file)
@@ -759,8 +759,6 @@ PyObject* PyModules::get_perf_schema_python(
   }
 
   PyFormatter f;
-  f.open_object_section("perf_schema");
-
   if (!daemons.empty()) {
     for (auto statepair : daemons) {
       auto key = statepair.first;
@@ -771,16 +769,16 @@ PyObject* PyModules::get_perf_schema_python(
       f.open_object_section(daemon_name.str().c_str());
 
       Mutex::Locker l(state->lock);
-      for (const auto &ctr_inst_iter : state->perf_counters.instances) {
-        const auto &typestr = ctr_inst_iter.first;
-
-       f.open_object_section(typestr.c_str());
-       auto type = state->perf_counters.types[typestr];
+      for (auto ctr_inst_iter : state->perf_counters.instances) {
+        const auto &counter_name = ctr_inst_iter.first;
+       f.open_object_section(counter_name.c_str());
+       auto type = state->perf_counters.types[counter_name];
        f.dump_string("description", type.description);
        if (!type.nick.empty()) {
          f.dump_string("nick", type.nick);
        }
        f.dump_unsigned("type", type.type);
+       f.dump_unsigned("priority", type.priority);
        f.close_section();
       }
       f.close_section();
@@ -789,7 +787,6 @@ PyObject* PyModules::get_perf_schema_python(
     dout(4) << __func__ << ": No daemon state found for "
               << svc_type << "." << svc_id << ")" << dendl;
   }
-  f.close_section();
   return f.get();
 }