From 2efd1bf9bbff94e08b2936f15f3f6ab136b3286b Mon Sep 17 00:00:00 2001 From: Nishanth Thomas Date: Thu, 8 May 2014 15:22:22 +0530 Subject: nagios-server-addons : Fixed cluster status plugin to correct queries BZ 1089641, changed the mk-livestatus query so that it picks the right services BZ 1089670, introduced a check to set status to OK if no volumes present in the cluster Bug-Url:https://bugzilla.redhat.com/show_bug.cgi?id=1089670 Bug:Url:https://bugzilla.redhat.com/show_bug.cgi?id=1089641 Change-Id: I93aed685c75ff3455e1129c0d8f9e485b6c5f2b0 Signed-off-by: Nishanth Thomas Reviewed-on: http://review.gluster.org/7708 Reviewed-by: Sahina Bose Tested-by: Sahina Bose --- plugins/check_cluster_status.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/check_cluster_status.py b/plugins/check_cluster_status.py index ab2a484..287cb2d 100755 --- a/plugins/check_cluster_status.py +++ b/plugins/check_cluster_status.py @@ -34,27 +34,24 @@ def findClusterStatus(clusterName): # Write command to socket cmd = "GET services\nColumns: state\n" \ "Filter: description ~~ %s\n" \ - "Filter: host_name = %s" % ('Volume Status', clusterName) + "Filter: host_name = %s" % ('Volume Status -', clusterName) table = livestatus.readLiveStatus(cmd) noOfVolumesInCriticalState = 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 noOfVolumesInCriticalState == noOfVolumes: - print "Cluster Status CRITICAL: All Volumes are in Critical State " \ - "| noOfVolumes=%s noOfVolumesInCriticalState=%s" \ - % (noOfVolumes, noOfVolumesInCriticalState) + print "CRITICAL: All Volumes in the cluster are in Critical State" exitStatus = utils.PluginStatusCode.CRITICAL elif noOfVolumesInCriticalState > 0: - print "Cluster Status WARNING : Some Volumes are in Critical State " \ - "| noOfVolumes=%s noOfVolumesInCriticalState=%s" \ - % (noOfVolumes, noOfVolumesInCriticalState) + print "WARNING : Some Volumes in the cluster are in Critical State" exitStatus = utils.PluginStatusCode.WARNING else: - print "Cluster Status OK : None of the Volumes are in Critical " \ - "State | noOfVolumes=%s noOfVolumesInCriticalState=%s" \ - % (noOfVolumes, noOfVolumesInCriticalState) + print "OK : None of the Volumes in the cluster are in Critical State" return exitStatus -- cgit