]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr_module: Deal with long running avgs properly
authorBoris Ranto <branto@redhat.com>
Tue, 15 May 2018 09:05:22 +0000 (11:05 +0200)
committerBoris Ranto <branto@redhat.com>
Fri, 1 Jun 2018 12:26:26 +0000 (14:26 +0200)
We have recently started exposing long running avgs with the mgr python
modules but that only covers the total sum, not the avgcount.

With this patch, the counts for long running avgs are exposed to the
python modules allowing them to deal with the new data.

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

Conflicts:
src/pybind/mgr/mgr_module.py: get_latest is inside
get_all_perf_counters, get_latest_avg added, too

src/pybind/mgr/mgr_module.py

index 933858151ff4d5b32a15749e971c61152719bf62..230d6f20b928d3d7ad9a86e45994af5f214480a7 100644 (file)
@@ -554,6 +554,13 @@ class MgrModule(ceph_module.BaseMgrModule):
             else:
                 return 0
 
+        def get_latest_avg(daemon_type, daemon_name, counter):
+            data = self.get_counter(daemon_type, daemon_name, counter)[counter]
+            if data:
+                return (data[-1][1], data[-1][2])
+            else:
+                return (0, 0)
+
         for server in self.list_servers():
             for service in server['services']:
                 if service['type'] not in ("rgw", "mds", "osd", "mon"):
@@ -579,8 +586,24 @@ class MgrModule(ceph_module.BaseMgrModule):
                     if counter_schema['priority'] < prio_limit:
                         continue
 
-                    counter_info = counter_schema
-                    counter_info['value'] = get_latest(service['type'], service['id'], counter_path)
+                    counter_info = dict(counter_schema)
+
+                    # Also populate count for the long running avgs
+                    if counter_schema['type'] & self.PERFCOUNTER_LONGRUNAVG:
+                        v, c = get_latest_avg(
+                            service['type'],
+                            service['id'],
+                            counter_path
+                        )
+                        counter_info['value'], counter_info['count'] = v, c
+                        result[svc_full_name][counter_path] = counter_info
+                    else:
+                        counter_info['value'] = get_latest(
+                            service['type'],
+                            service['id'],
+                            counter_path
+                        )
+
                     result[svc_full_name][counter_path] = counter_info
 
         self.log.debug("returning {0} counter".format(len(result)))