From 05c2cd7c527d3a7e8b1244db72505314c3e82d3a Mon Sep 17 00:00:00 2001 From: Sahina Bose Date: Tue, 27 May 2014 17:04:36 +0530 Subject: plugins: Geo-rep plugin status message enhanced Added geo-rep session wise details to the plugin output. Change-Id: I2086a493c2befa4c1e25a1cc5523213f0f13c8dd Bug-Url: https://bugzilla.redhat.com/1101218 Bug-Url: https://bugzilla.redhat.com/1101223 Signed-off-by: Sahina Bose Reviewed-on: http://review.gluster.org/7896 --- plugins/check_volume_status.py | 32 ++++++++++++++++++-------------- tests/test_check_volume_status.py | 24 ++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/plugins/check_volume_status.py b/plugins/check_volume_status.py index e2b9205..4812e99 100755 --- a/plugins/check_volume_status.py +++ b/plugins/check_volume_status.py @@ -115,20 +115,24 @@ def getVolumeGeoRepStatus(args): exitstatus = utils.PluginStatusCode.UNKNOWN message = "UNKNOWN: Volume info not found" else: - if (volume[args.volume]['status'] == - glustercli.GeoRepStatus.PARTIAL_FAULTY): - exitstatus = utils.PluginStatusCode.WARNING - message = "Partially faulty\n %s" % volume[args.volume]['detail'] - elif volume[args.volume]['status'] == glustercli.GeoRepStatus.FAULTY: - exitstatus = utils.PluginStatusCode.CRITICAL - message = "Faulty\n %s" % volume[args.volume]['detail'] - elif (volume[args.volume]['status'] == - glustercli.GeoRepStatus.NOT_STARTED): - exitstatus = utils.PluginStatusCode.WARNING - message = "Not Started" - else: - exitstatus = utils.PluginStatusCode.OK - message = "OK" + exitstatus = utils.PluginStatusCode.OK + message = "Session status:" + detail = "Details:" + for slavename, slave_dict in volume[args.volume]['slaves'].iteritems(): + message += ("%s - %s " % (slavename, + slave_dict['status'])) + detail += ("%s - %s " % (slavename, + slave_dict['detail'])) + if slave_dict['status'] == glustercli.GeoRepStatus.FAULTY: + exitstatus = utils.PluginStatusCode.CRITICAL + elif (slave_dict['status'] + in [glustercli.GeoRepStatus.PARTIAL_FAULTY, + glustercli.GeoRepStatus.STOPPED, + glustercli.GeoRepStatus.NOT_STARTED] + and exitstatus == utils.PluginStatusCode.OK): + exitstatus = utils.PluginStatusCode.WARNING + if exitstatus != utils.PluginStatusCode.OK: + message += "\n" + detail return exitstatus, message diff --git a/tests/test_check_volume_status.py b/tests/test_check_volume_status.py index c1ffa32..02d0bba 100644 --- a/tests/test_check_volume_status.py +++ b/tests/test_check_volume_status.py @@ -133,5 +133,25 @@ def _getQuotaStatusOk(): def _getGeoRepStatus(status): - return {'test-vol': {'status': status, - 'detail': "rhs3-2.novalocal - faulty;"}} + return {'test-vol': {'slaves': + {'10.70.43.68::slave-vol': + {'faulty': 1, + 'nodecount': 2, + 'notstarted': 0, + 'stopped': 0, + 'detail': 'rhs3.novalocal:/bricks/b3 ' + '- Passive;' + 'rhs3-2.novalocal:/bricks/b3 ' + '- FAULTY;', + 'status': status}, + '10.70.43.68::slave-vol2': + {'faulty': 0, + 'nodecount': 2, + 'notstarted': 2, + 'stopped': 0, + 'detail': 'rhs3.novalocal:/bricks/b3 ' + '- NOT_STARTED;' + 'rhs3-2.novalocal:/bricks/b3 ' + '- NOT_STARTED;', + 'status': "NOT_STARTED"} + }}} -- cgit