1
0
mirror of https://github.com/opinkerfi/nagios-plugins.git synced 2024-11-23 10:53:44 +01:00

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.
This commit is contained in:
Tomas Edwardsson 2014-03-07 11:25:24 +00:00
parent d11d29185a
commit 55daf8f4c9

View File

@ -72,12 +72,11 @@ def getLocalNodeState(dom):
""" """
Get the state of the local node Get the state of the local node
""" """
hostname = socket.gethostname()
nodesList = dom.getElementsByTagName('node') nodesList = dom.getElementsByTagName('node')
nodeState = {} nodeState = {}
for node in nodesList: for node in nodesList:
if node.attributes['name'].value == hostname: if node.attributes['local'].value == "1":
nodeState['name'] = node.attributes['name'].value nodeState['name'] = node.attributes['name'].value
nodeState['state'] = node.attributes['state'].value nodeState['state'] = node.attributes['state'].value
nodeState['rgmanager'] = node.attributes['rgmanager'].value nodeState['rgmanager'] = node.attributes['rgmanager'].value
@ -95,7 +94,6 @@ def getServiceState(dom, service):
Get the state of the named service Get the state of the named service
""" """
groupList = dom.getElementsByTagName('group') groupList = dom.getElementsByTagName('group')
hostname = socket.gethostname()
serviceState = {} serviceState = {}
for group in groupList: for group in groupList:
if group.attributes['name'].value in (service,"service:"+service,"vm:"+service): if group.attributes['name'].value in (service,"service:"+service,"vm:"+service):