From f29c69c222f88fffcd53d01c718eda607ddbe33a Mon Sep 17 00:00:00 2001 From: Kanagaraj M Date: Thu, 17 Apr 2014 10:35:24 +0530 Subject: check-proc: Fix issues in SHD and NFS - Skipped OFFLINE volumes for checking nfs option - Fixed a loop issue in SHD Change-Id: I76a07ceb6724c6d723aec135021501518341fab7 Signed-off-by: Kanagaraj M --- plugins/check_proc_status.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/check_proc_status.py b/plugins/check_proc_status.py index 20b7b32..47cf71e 100755 --- a/plugins/check_proc_status.py +++ b/plugins/check_proc_status.py @@ -89,8 +89,10 @@ def sendNfsStatus(hostName, volInfo): # if nfs is not running and any of the volume uses nfs # then its required to alert the user - for k, v in volInfo.iteritems(): - nfsStatus = v.get('options', {}).get('nfs.disable', 'off') + for volume, volumeInfo in volInfo.iteritems(): + if volumeInfo['volumeStatus'] == glustercli.VolumeStatus.OFFLINE: + continue + nfsStatus = volumeInfo.get('options', {}).get('nfs.disable', 'off') if nfsStatus == 'off': msg = "CRITICAL: Process glusterfs-nfs is not running" status = utils.PluginStatusCode.CRITICAL @@ -153,18 +155,24 @@ def sendShdStatus(hostName, volInfo): for volumeName, volumeInfo in volInfo.iteritems(): if volumeInfo['volumeStatus'] == glustercli.VolumeStatus.OFFLINE: continue - for brick in volumeInfo['bricksInfo']: - if brick['hostUuid'] == hostUuid and \ - int(volumeInfo['replicaCount']) > 1: - status = utils.PluginStatusCode.CRITICAL - msg = "CRITICAL: Gluster Self Heal Daemon not running" - break + if hasBricks(hostUuid, volumeInfo['bricksInfo']) and \ + int(volumeInfo['replicaCount']) > 1: + status = utils.PluginStatusCode.CRITICAL + msg = "CRITICAL: Gluster Self Heal Daemon not running" + break else: msg = "OK: Process Gluster Self Heal Daemon" status = utils.PluginStatusCode.OK nscautils.send_to_nsca(hostName, _shdService, status, msg) +def hasBricks(hostUuid, bricks): + for brick in bricks: + if brick['hostUuid'] == hostUuid: + return True + return False + + if __name__ == '__main__': hostName = nscautils.getCurrentHostNameInNagiosServer() if not hostName: -- cgit