]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: expose avg data for long running avgs 22420/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 11:58:03 +0000 (13:58 +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>
src/mgr/ActivePyModules.cc

index cbd9b9571558f2fd12cc0ee82657c244276f2c00..fdf6652fed9e145e1add3d5724f5caa6069e141b 100644 (file)
@@ -591,20 +591,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();
         }
       }