From f79ff11302a0364c04601b5ccd3950d80cd063a8 Mon Sep 17 00:00:00 2001 From: Boris Ranto Date: Tue, 15 May 2018 11:05:22 +0200 Subject: [PATCH] mgr_module: Deal with long running avgs properly 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 --- src/pybind/mgr/mgr_module.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 80e7552b9bb49..1db2e71a425e3 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -692,6 +692,13 @@ class MgrModule(ceph_module.BaseMgrModule): else: return 0 + def get_latest_avg(self, 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) + def get_all_perf_counters(self, prio_limit=PRIO_USEFUL): """ Return the perf counters currently known to this ceph-mgr @@ -733,9 +740,24 @@ class MgrModule(ceph_module.BaseMgrModule): if counter_schema['priority'] < prio_limit: continue - counter_info = counter_schema - counter_info['value'] = self.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 = self.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'] = self.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))) -- 2.39.5