From f3f73cde3b85e1b12f531e3f5ed6164e0d02c614 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Tue, 10 Jan 2017 12:17:13 +0100 Subject: [PATCH] check general health for ceph monitors, not only time we did not check the healthservices array for the monitor widget, this patch does that, and takes the worst health state Signed-off-by: Dominik Csapak --- www/manager6/ceph/StatusDetail.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/www/manager6/ceph/StatusDetail.js b/www/manager6/ceph/StatusDetail.js index 1d3d3c28..6517ab7b 100644 --- a/www/manager6/ceph/StatusDetail.js +++ b/www/manager6/ceph/StatusDetail.js @@ -95,7 +95,10 @@ Ext.define('PVE.ceph.StatusDetail', { !record.data.health || !record.data.health.timechecks || !record.data.monmap || - !record.data.monmap.mons) { + !record.data.monmap.mons || + !record.data.health.health || + !record.data.health.health.health_services || + !record.data.health.health.health_services[0]) { // only continue if we have all the data return; } @@ -159,7 +162,9 @@ Ext.define('PVE.ceph.StatusDetail', { }); var monTimes = record.data.health.timechecks.mons || []; + var monHealth = record.data.health.health.health_services[0].mons || []; var timechecks = {}; + var healthchecks = {}; var monContainer = me.getComponent('monitors'); var i; for (i = 0; i < mons.length && i < monTimes.length; i++) { @@ -170,6 +175,10 @@ Ext.define('PVE.ceph.StatusDetail', { timechecks[mons[0].name] = "HEALTH_OK"; } + for (i = 0; i < mons.length && i < monHealth.length; i++) { + healthchecks[monHealth[i].name] = monHealth[i].health; + } + for (i = 0; i < mons.length; i++) { var monitor = monContainer.getComponent('mon.' + mons[i].name); if (!monitor) { @@ -181,7 +190,7 @@ Ext.define('PVE.ceph.StatusDetail', { itemId: 'mon.' + mons[i].name }); } - monitor.updateMonitor(timechecks[mons[i].name], mons[i], record.data.quorum_names); + monitor.updateMonitor(timechecks[mons[i].name], mons[i], record.data.quorum_names, healthchecks[mons[i].name]); } me.suspendLayout = false; me.updateLayout(); @@ -209,16 +218,22 @@ Ext.define('PVE.ceph.MonitorWidget', { // timestate: the status from timechecks.mons // data: the monmap.mons data // quorum_names: the quorum_names array - updateMonitor: function(timestate, data, quorum_names) { + updateMonitor: function(timestate, data, quorum_names, health) { var me = this; var state = 'HEALTH_ERR'; + var healthstates = { + 'HEALTH_OK': 3, + 'HEALTH_WARN': 2, + 'HEALTH_ERR': 1 + }; // if the monitor is part of the quorum // and has a timestate, get the timestate, // otherwise the state is ERR - if (timestate && quorum_names && + if (timestate && health && quorum_names && quorum_names.indexOf(data.name) !== -1) { - state = timestate; + state = (healthstates[health] < healthstates[timestate])? + health : timestate; } me.update(Ext.apply(me.data, {