From 397d3b935019c6290b922933f39e956104466e4d Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 26 Jun 2017 14:27:38 -0400 Subject: [PATCH] mgr/dashboard: update for new style health checks Signed-off-by: John Spray --- src/pybind/mgr/dashboard/base.html | 21 +++++++++++++++------ src/pybind/mgr/dashboard/health.html | 12 ++++++++---- src/pybind/mgr/dashboard/module.py | 19 +++++++++++++++++-- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/pybind/mgr/dashboard/base.html b/src/pybind/mgr/dashboard/base.html index e7256d1ba0a..18874fb565f 100644 --- a/src/pybind/mgr/dashboard/base.html +++ b/src/pybind/mgr/dashboard/base.html @@ -39,7 +39,7 @@ var refresh = function() { $.get("/toplevel_data", function(data) { - _.extend(toplevel_data.health, data.health); + _.extend(toplevel_data, data); setTimeout(refresh, refresh_interval); }); }; @@ -60,6 +60,14 @@ } } + rivets.formatters.health_ok = function(status_str) { + if (status_str == "HEALTH_OK") { + return true; + } else { + return false; + } + } + var truncate = function(n, max_width) { var stringized = n.toString(); var parts = stringized.split("."); @@ -106,7 +114,7 @@ - rivets.bind($("#health"), toplevel_data.health); + rivets.bind($("#health"), toplevel_data); rivets.bind($("section.sidebar"), toplevel_data); setTimeout(refresh, refresh_interval); }); @@ -140,10 +148,11 @@ Toggle navigation -
- Health:  - - {overall_status} +
+ + + {health_status} +
diff --git a/src/pybind/mgr/dashboard/health.html b/src/pybind/mgr/dashboard/health.html index e41a1e2da5e..de5a794f27d 100644 --- a/src/pybind/mgr/dashboard/health.html +++ b/src/pybind/mgr/dashboard/health.html @@ -99,12 +99,16 @@
- Overall status: {health.overall_status} +
+ Overall status: {health.status}
    -
  • - {summary.severity}: {summary.summary} -
  • +
      +
    • + {check.type}: + {check.message} +
    • +
diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 2576680e395..93300135f49 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -434,8 +434,8 @@ class Module(MgrModule): ] return { - 'health': global_instance().get_sync_object(Health).data, 'rbd_pools': rbd_pools, + 'health_status': self._health_data()['status'], 'filesystems': filesystems } @@ -635,6 +635,21 @@ class Module(MgrModule): def servers_data(self): return self._servers() + def _health_data(self): + health = global_instance().get_sync_object(Health).data + # Transform the `checks` dict into a list for the convenience + # of rendering from javascript. + checks = [] + for k, v in health['checks'].iteritems(): + v['type'] = k + checks.append(v) + + checks = sorted(checks, cmp=lambda a, b: a['severity'] > b['severity']) + + health['checks'] = checks + + return health + def _health(self): # Fuse osdmap with pg_summary to get description of pools # including their PG states @@ -670,7 +685,7 @@ class Module(MgrModule): del osd_map['pg_temp'] return { - "health": global_instance().get_sync_object(Health).data, + "health": self._health_data(), "mon_status": global_instance().get_sync_object( MonStatus).data, "osd_map": osd_map, -- 2.39.5