From 55daf8f4c9a5f0189f6507518e4497bb41841897 Mon Sep 17 00:00:00 2001 From: Tomas Edwardsson Date: Fri, 7 Mar 2014 11:25:24 +0000 Subject: [PATCH] Rework hostname detection to use local Removed socket.gethostname to discover own hostname instead using the local flag which is output from /usr/sbin/clustat -fx node definitions. The gethostname does not always match the cluster node name which would make the check fail. --- check_rhcs/check_rhcs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/check_rhcs/check_rhcs b/check_rhcs/check_rhcs index 4aeb022..a235498 100644 --- a/check_rhcs/check_rhcs +++ b/check_rhcs/check_rhcs @@ -72,12 +72,11 @@ def getLocalNodeState(dom): """ Get the state of the local node """ - hostname = socket.gethostname() nodesList = dom.getElementsByTagName('node') nodeState = {} for node in nodesList: - if node.attributes['name'].value == hostname: + if node.attributes['local'].value == "1": nodeState['name'] = node.attributes['name'].value nodeState['state'] = node.attributes['state'].value nodeState['rgmanager'] = node.attributes['rgmanager'].value @@ -95,7 +94,6 @@ def getServiceState(dom, service): Get the state of the named service """ groupList = dom.getElementsByTagName('group') - hostname = socket.gethostname() serviceState = {} for group in groupList: if group.attributes['name'].value in (service,"service:"+service,"vm:"+service):