From a1331a6ece5f7852fe32d32f145817798fd1a3b5 Mon Sep 17 00:00:00 2001 From: Yang Honggang Date: Tue, 17 Sep 2019 23:30:30 +0800 Subject: [PATCH] pybind/mgr/balancer/module.py: add max/min info in stats_by_root $ ceph balancer eval-verbose hahapool ... count_by_pool {'hahapool': {'objects': {0: 1L, 1: 1L, 2: 0L, 3: 0L, 4: 1L}, 'bytes': {0: 0L, 1: 0L, 2: 0L, 3: 0L, 4: 0L}, 'pgs': {0: 35, 1: 42, 2: 23, 3: 30, 4: 26}}} ... stats_by_root {'default': {'objects': {'min': 0.0, 'max': 1.0, 'score': 0.2970089549436925, 'stddev': 0.5477225575051662, 'avg': 0.6, 'sum_weight': 0.6000000000000001}, 'bytes': {'min': 0, 'max': 0, 'score': 0, 'stddev': 0, 'avg': 0, 'sum_weight': 0}, 'pgs': {'min': 23.0, 'max': 42.0, 'score': 0.07354228523075643, 'stddev': 7.52994023880668, 'avg': 31.2, 'sum_weight': 0.4}}} max/min can give us an intuitive feel of the pg/bytes/object's distribution. In addition, sometimes we really want to know which osd hold the most number of pgs/bytes/objects for specified pool. Signed-off-by: Yang Honggang --- src/pybind/mgr/balancer/module.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index 8b9cc63e13dee..758aadd5721d0 100644 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@ -141,6 +141,8 @@ class Eval: for t in ('pgs', 'objects', 'bytes'): if total[t] == 0: r[t] = { + 'max': 0, + 'min': 0, 'avg': 0, 'stddev': 0, 'sum_weight': 0, @@ -189,6 +191,8 @@ class Eval: stddev = math.sqrt(dev / float(max(num - 1, 1))) score = score / max(sum_weight, 1) r[t] = { + 'max': max(count[t].values()), + 'min': min(count[t].values()), 'avg': avg, 'stddev': stddev, 'sum_weight': sum_weight, -- 2.39.5