From af2463b0c05d2618b1b83e82873bf0570dccf068 Mon Sep 17 00:00:00 2001 From: Ramesh Nachimuthu Date: Wed, 5 Nov 2014 15:57:13 +0530 Subject: server-plugin: consider all status of volume in cluster status Consider the 'UNKNOWN' status of volumes while calculating the cluster status. Following will be the cluster state and state information. Cluster State State Information UP "OK : None of the Volumes in the cluster are in Critical State" UP "OK : No Volumes present in the cluster" UP "WARNING : Some Volumes in the cluster are in Critical State" UP "WARNING : Some Volumes in the cluster are in Unknown State" UP "WARNING : Some Volumes in the cluster are in Warning State" UP "WARNING : All Volumes in the cluster are in Warning State" DOWN "CRITICAL: All Volumes in the cluster are in Critical State" DOWN "CRITICAL: All Volumes in the cluster are in Unknown State" Bug-url: https://bugzilla.redhat.com/1128007 Change-Id: I06fb1697cb4919420ab6d6ea54e9d9ee96820d2a Signed-off-by: Ramesh Nachimuthu Reviewed-on: http://review.gluster.org/9053 Reviewed-by: Shubhendu Tripathi Reviewed-by: Sahina Bose --- plugins/check_cluster_status.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/plugins/check_cluster_status.py b/plugins/check_cluster_status.py index 287cb2d..ee9050c 100755 --- a/plugins/check_cluster_status.py +++ b/plugins/check_cluster_status.py @@ -37,19 +37,39 @@ def findClusterStatus(clusterName): "Filter: host_name = %s" % ('Volume Status -', clusterName) table = livestatus.readLiveStatus(cmd) noOfVolumesInCriticalState = 0 + noOfVolumesInUnknownState = 0 + noOfVolumesInWarningState = 0 noOfVolumes = len(table) if noOfVolumes == 0: print "OK : No Volumes present in the cluster" return exitStatus for row in table: - if len(row) > 0 and row[0] == '2': - noOfVolumesInCriticalState += 1 + if len(row) > 0: + if row[0] == '1': + noOfVolumesInWarningState += 1 + elif row[0] == '2': + noOfVolumesInCriticalState += 1 + elif row[0] == '3': + noOfVolumesInUnknownState += 1 + if noOfVolumesInCriticalState == noOfVolumes: print "CRITICAL: All Volumes in the cluster are in Critical State" exitStatus = utils.PluginStatusCode.CRITICAL + elif noOfVolumesInUnknownState == noOfVolumes: + print "CRITICAL: All Volumes in the cluster are in Unknown State" + exitStatus = utils.PluginStatusCode.CRITICAL elif noOfVolumesInCriticalState > 0: print "WARNING : Some Volumes in the cluster are in Critical State" exitStatus = utils.PluginStatusCode.WARNING + elif noOfVolumesInUnknownState > 0: + print "WARNING : Some Volumes in the cluster are in Unknown State" + exitStatus = utils.PluginStatusCode.WARNING + elif noOfVolumesInWarningState == noOfVolumes: + print "WARNING : All Volumes in the cluster are in Warning State" + exitStatus = utils.PluginStatusCode.WARNING + elif noOfVolumesInWarningState > 0: + print "WARNING : Some Volumes in the cluster are in Warning State" + exitStatus = utils.PluginStatusCode.WARNING else: print "OK : None of the Volumes in the cluster are in Critical State" return exitStatus -- cgit