From c7fa43e3dd1aa63d20caac8d6ffd85735614d832 Mon Sep 17 00:00:00 2001 From: Nishanth Thomas Date: Fri, 7 Nov 2014 01:07:45 +0530 Subject: nagios-server-addons:_executeRandomHost to check for the status of glusterd service During the creation of eligible list of hosts, need to consider the status of glusterd service also. this is included. Also added some additional checks to handle the errors https://bugzilla.redhat.com/show_bug.cgi?id=1136205 https://bugzilla.redhat.com/show_bug.cgi?id=1109843 Signed-off-by: Nishanth Thomas Change-Id: Ic757ecc0df5ef3c261048a961af59715ca889a26 Reviewed-on: http://review.gluster.org/9066 Reviewed-by: Ramesh N Tested-by: Nishanth Thomas Reviewed-by: Shubhendu Tripathi Reviewed-by: Sahina Bose --- plugins/check_vol_server.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/check_vol_server.py b/plugins/check_vol_server.py index cabc1bc..f6c11d3 100755 --- a/plugins/check_vol_server.py +++ b/plugins/check_vol_server.py @@ -14,13 +14,24 @@ def _getListHosts(hostgroup): table = json.loads(livestatus.readLiveStatusAsJSON( "GET hostgroups\nColumns: members_with_state\n" "Filter: name = " + hostgroup + "\n"))[0][0] - # Get the only those nodes which are UP + # Get the only those nodes which are UP and + #glusterd service is running for row in table: - if row[1] == utils.HostStatusCode.UP: + if row[1] == utils.HostStatusCode.UP and \ + _getGlusterdStatus(row[0]) \ + == utils.PluginStatusCode.OK: list_hosts.append(row[0]) return list_hosts +def _getGlusterdStatus(hostname): + status = json.loads(livestatus.readLiveStatusAsJSON( + "GET services\nColumns: state\n" + "Filter: description = Gluster Management\n" + "Filter: host_name = " + hostname + "\n"))[0][0] + return status + + def _getHostAddress(host): # Get the address of the host host_address = livestatus.checkLiveStatus("GET hosts\nColumns: address\n" @@ -102,6 +113,8 @@ def _getVolumeStatusOutput(hostgroup, volume): # Get volume details nrpeStatus, nrpeOut = _executeRandomHost( hostgroup, _getVolDetailNRPECommand(volume)) + if nrpeStatus != utils.PluginStatusCode.OK: + return utils.PluginStatusCode.UNKNOWN, nrpeOut volInfo = json.loads(nrpeOut) # Get the volume type vol_type = volInfo[volume]['type'] -- cgit