From d7a60096f85b68f84c7f9fb20e88fd700699755c Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 3 Oct 2017 16:52:48 +0200 Subject: gluster-nagios: detect .pid files under /var/run/gluster/vols/ New versions of Gluster place .pid files for volumes under /var/run/gluster/vols/ instead of the previous /var/lib/glusterd/vols/ directory. In order to support both variants, look for the .pid file in both locations. BUG: 1498112 Change-Id: I605c611d792cfe29c212bb2eb9d14df2e589502c Reported-by: Pamela Ousley Signed-off-by: Niels de Vos Reviewed-on: https://review.gluster.org/18425 Reviewed-by: Sahina Bose Tested-by: Sahina Bose --- plugins/check_proc_util.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/plugins/check_proc_util.py b/plugins/check_proc_util.py index 28c19ef..54c67a0 100755 --- a/plugins/check_proc_util.py +++ b/plugins/check_proc_util.py @@ -34,7 +34,8 @@ _chkConfig = utils.CommandPath('chkconfig', _chkService = utils.CommandPath('service', '/sbin/service', 'usr/sbin/service') -_glusterVolPath = "/var/lib/glusterd/vols" +_glusterVolRunFmt = ["/var/run/gluster/vols/%s/", + "/var/lib/glusterd/vols/%s/run/"] _checkGlusterService = [_chkService.cmd, "glusterd", "status"] _checkNfsCmd = [_checkProc.cmd, "-c", "1:", "-C", "glusterfs", "-a", "nfs"] _checkShdCmd = [_checkProc.cmd, "-c", "1:", "-C", "glusterfs", "-a", @@ -69,8 +70,20 @@ def getBrickStatus(volumeName, brickName): brickPath = brickName.split(':')[1] pidFile = brickName.replace(":/", "-").replace("/", "-") + ".pid" try: - with open("%s/%s/run/%s" % ( - _glusterVolPath, volumeName, pidFile)) as f: + brickPidFile = None + for fmt in _glusterVolRunFmt: + brickPidFile = (fmt % (volumeName)) + pidFile + if os.path.exists(brickPidFile): + break + else: + brickPidFile = None + + if not brickPidFile: + status = utils.PluginStatusCode.CRITICAL + msg = "Could not find pid for brick %s" % (brickPath) + return status, msg + + with open(brickPidFile) as f: try: if _pidExists(int(f.read().strip())): status = utils.PluginStatusCode.OK -- cgit