[pve-devel] [PATCH manager 2/2] check general health for ceph monitors, not only time

Dominik Csapak d.csapak at proxmox.com
Tue Jan 10 12:17:13 CET 2017


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 <d.csapak at proxmox.com>
---
i have no idea if i interpreted the ceph json structure right,
but it had always this structure in my tests, and it is not documented
anywhere
 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 1d3d3c2..6517ab7 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, {
-- 
2.1.4




More information about the pve-devel mailing list