]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: expose avg data for long running avgs 22366/head
authorBoris Ranto <branto@redhat.com>
Tue, 5 Jun 2018 11:58:00 +0000 (13:58 +0200)
committerBoris Ranto <branto@redhat.com>
Tue, 5 Jun 2018 16:50:22 +0000 (18:50 +0200)
While exposing the long running avgs, the order of regular and long
running avg data got mixed up resulting in exposing empty data for both
since there is no regular data for long running avgs and vice versa.
This commit fixes this issue by changing the order of the if/else
statement exposing regular data for regular counters and avg data for
long running avgs.

Signed-off-by: Boris Ranto <branto@redhat.com>
(cherry picked from commit 2042c6c27beb504454daaaf185b9ce8f04d679d9)

src/mgr/ActivePyModules.cc

index 058282fb0b4aa22f6622676c4be9e9d14f5c3515..0694d23082e4f511a6a0f782352a1582ea58fec2 100644 (file)
@@ -560,20 +560,20 @@ PyObject* ActivePyModules::get_counter_python(
       auto counter_instance = metadata->perf_counters.instances.at(path);
       auto counter_type = metadata->perf_counters.types.at(path);
       if (counter_type.type & PERFCOUNTER_LONGRUNAVG) {
-        const auto &data = counter_instance.get_data();
-        for (const auto &datapoint : data) {
+        const auto &avg_data = counter_instance.get_data_avg();
+        for (const auto &datapoint : avg_data) {
           f.open_array_section("datapoint");
           f.dump_unsigned("t", datapoint.t.sec());
-          f.dump_unsigned("v", datapoint.v);
+          f.dump_unsigned("s", datapoint.s);
+          f.dump_unsigned("c", datapoint.c);
           f.close_section();
         }
       } else {
-        const auto &avg_data = counter_instance.get_data_avg();
-        for (const auto &datapoint : avg_data) {
+        const auto &data = counter_instance.get_data();
+        for (const auto &datapoint : data) {
           f.open_array_section("datapoint");
           f.dump_unsigned("t", datapoint.t.sec());
-          f.dump_unsigned("s", datapoint.s);
-          f.dump_unsigned("c", datapoint.c);
+          f.dump_unsigned("v", datapoint.v);
           f.close_section();
         }
       }