mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2024-11-26 20:33:46 +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:
parent
d11d29185a
commit
55daf8f4c9
@ -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):
|
||||||
|
Loading…
Reference in New Issue
Block a user