]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/telemetry: modify stats_per_pool
authorLaura Flores <lflores@redhat.com>
Thu, 4 Nov 2021 17:55:51 +0000 (17:55 +0000)
committerLaura Flores <lflores@redhat.com>
Thu, 4 Nov 2021 21:38:29 +0000 (21:38 +0000)
There is a much easier way to collect stats_per_pool than the current implementation. Fetching 'pg_dump' from the mgr module already provides a field called "pool_stats" that is the same as aggregated pg stats, which was the implementation up until this commit.

All in all, this solution should provide the information we want, with a much cleaner implementation.

Signed-off-by: Laura Flores <lflores@redhat.com>
Backport Message: In the case that this commit is backported, it is important to note that the commits in PR #42569 should be backported first, as the implementation of "get_stat_sum_per_pool()" in #42569 precedes the removal of it here.

src/pybind/mgr/telemetry/module.py

index e54a4621891ff6c5c03fbd86bd04a921b582d7b7..15203188727ee38ea655e0c743a629dc9b5eb8dd 100644 (file)
@@ -338,52 +338,6 @@ class Module(MgrModule):
 
         return result
 
-    def get_stat_sum_per_pool(self) -> List[dict]:
-        # Initialize 'result' list
-        result: List[dict] = []
-
-        # Create a list of pool ids that will later act as a queue, i.e.:
-        #   pool_queue = [1, 2, 3]
-        osd_map = self.get('osd_map')
-        pool_queue = []
-        for pool in osd_map['pools']:
-            pool_queue.append(str(pool['pool']))
-
-        # Populate 'result', i.e.:
-        #   {
-        #       'pool_id': '1'
-        #       'stats_sum': {
-        #           'num_bytes': 36,
-        #           'num_bytes_hit_set_archive': 0,
-        #           ...
-        #           'num_write_kb': 0
-        #           }
-        #       }
-        #   }
-        while pool_queue:
-            # Pop the current pool id out of pool_queue
-            curr_pool_id = pool_queue.pop(0)
-
-            # Initialize a dict that will hold aggregated stats for the current pool
-            compiled_stats_dict: Dict[str, Any] = defaultdict(lambda: defaultdict(int))
-
-            # Find out which pgs belong to the current pool and add up
-            # their stats
-            pg_dump = self.get('pg_dump')
-            for pg in pg_dump['pg_stats']:
-                pool_id = pg['pgid'].split('.')[0]
-                if pool_id == curr_pool_id:
-                    compiled_stats_dict['pool_id'] = int(pool_id)
-                    for metric in pg['stat_sum']:
-                        compiled_stats_dict['stats_sum'][metric] += pg['stat_sum'][metric]
-                else:
-                    continue
-            # 'compiled_stats_dict' now holds all stats pertaining to
-            # the current pool. Adding it to the list of results.
-            result.append(compiled_stats_dict)
-
-        return result
-
     def get_osd_histograms(self, mode: str = 'separated') -> List[Dict[str, dict]]:
         # Initialize result dict
         result: Dict[str, dict] = defaultdict(lambda: defaultdict(
@@ -949,7 +903,8 @@ class Module(MgrModule):
             report['perf_counters_aggregated'] = self.gather_perf_counters('aggregated')
             report['perf_counters_separated'] = self.gather_perf_counters('separated')
 
-            report['stat_sum_per_pool'] = self.get_stat_sum_per_pool()
+            report['stats_per_pool'] = self.get('pg_dump')['pool_stats']
+
             report['io_rate'] = self.get_io_rate()
 
             report['osd_perf_histograms_aggregated'] = self.get_osd_histograms('aggregated')