From 9a624209a41d24f5cda23f2bb2e2c0efb7f1e35b Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Thu, 15 Nov 2018 13:29:52 -0800 Subject: [PATCH] pybind/mgr: add osd space utilization to insights report Signed-off-by: Noah Watkins --- src/pybind/mgr/insights/module.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/pybind/mgr/insights/module.py b/src/pybind/mgr/insights/module.py index 613fdbed7ea..9f59920f54e 100644 --- a/src/pybind/mgr/insights/module.py +++ b/src/pybind/mgr/insights/module.py @@ -200,6 +200,24 @@ class Module(MgrModule): return result, health_check_details + def _apply_osd_stats(self, osd_map): + # map from osd id to its index in the map structure + osd_id_to_idx = {} + for idx in range(len(osd_map["osds"])): + osd_id_to_idx[osd_map["osds"][idx]["osd"]] = idx + + # include stats, including space utilization performance counters. + # adapted from dashboard api controller + for s in self.get('osd_stats')['osd_stats']: + idx = osd_id_to_idx[s["osd"]] + osd_map["osds"][idx].update({'osd_stats': s}) + + for osd in osd_map["osds"]: + osd['stats'] = {} + for s in ['osd.numpg', 'osd.stat_bytes', 'osd.stat_bytes_used']: + osd['stats'][s.split('.')[1]] = self.get_latest('osd', str(osd["osd"]), s) + + def _config_dump(self): """Report cluster configuration @@ -241,6 +259,7 @@ class Module(MgrModule): osd_map = self.get("osd_map") del osd_map['pg_temp'] + self._apply_osd_stats(osd_map) report["osd_dump"] = osd_map report["df"] = self.get("df") -- 2.47.3