mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2025-04-20 06:13:40 +02:00
Merge d9e89bc358
into ffbdd754d4
This commit is contained in:
commit
ff8d256552
@ -1,6 +1,4 @@
|
|||||||
#!/bin/env python
|
#!/bin/env python
|
||||||
|
|
||||||
#
|
|
||||||
# Gather the cluster state and the current node state
|
# Gather the cluster state and the current node state
|
||||||
#
|
#
|
||||||
# Output example:
|
# Output example:
|
||||||
@ -23,6 +21,14 @@
|
|||||||
#</clustat>
|
#</clustat>
|
||||||
#
|
#
|
||||||
# Frank Clements <frank @ sixthtoe.net>
|
# Frank Clements <frank @ sixthtoe.net>
|
||||||
|
#
|
||||||
|
# INFO : In RHEL 5, there is a bug in clustat preventing non-root users to use
|
||||||
|
# clustat. See https://bugzilla.redhat.com/show_bug.cgi?id=531273
|
||||||
|
# You might need to use setuid on clustat to change this if rgmanager cannot be
|
||||||
|
# upgraded to 3.0.7+
|
||||||
|
# $chown root:nagios /usr/sbin/clustat
|
||||||
|
# $chmod u+s /usr/sbin/clustat
|
||||||
|
|
||||||
|
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
import os
|
import os
|
||||||
@ -112,6 +118,7 @@ def main():
|
|||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
check_suspend = False
|
check_suspend = False
|
||||||
|
typeCheck = None
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
if o in ('-c', '--cluster'):
|
if o in ('-c', '--cluster'):
|
||||||
typeCheck = 'cluster'
|
typeCheck = 'cluster'
|
||||||
@ -124,6 +131,10 @@ def main():
|
|||||||
usage()
|
usage()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
if typeCheck == None:
|
||||||
|
usage()
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
clustatOutput = os.popen('/usr/sbin/clustat -fx')
|
clustatOutput = os.popen('/usr/sbin/clustat -fx')
|
||||||
dom = xml.dom.minidom.parse(clustatOutput)
|
dom = xml.dom.minidom.parse(clustatOutput)
|
||||||
@ -133,7 +144,7 @@ def main():
|
|||||||
if typeCheck == 'cluster':
|
if typeCheck == 'cluster':
|
||||||
|
|
||||||
# First we query for the state of the cluster itself.
|
# First we query for the state of the cluster itself.
|
||||||
# Should it be found tha the cluste ris not quorate we alert and exit immediately
|
# Should it be found that the cluster is not quorate we alert and exit immediately
|
||||||
cluster = getClusterName(dom)
|
cluster = getClusterName(dom)
|
||||||
qState = getQuorumState(dom)
|
qState = getQuorumState(dom)
|
||||||
|
|
||||||
@ -145,12 +156,15 @@ def main():
|
|||||||
# Now we find the status of the local node from clustat.
|
# Now we find the status of the local node from clustat.
|
||||||
# We only care about the local state since this way we can tie the alert to the host.
|
# We only care about the local state since this way we can tie the alert to the host.
|
||||||
nodeStates = getLocalNodeState(dom)
|
nodeStates = getLocalNodeState(dom)
|
||||||
|
if nodeStates == {}:
|
||||||
|
print "UNKNOWN: Local node informations couldn't be found!"
|
||||||
|
sys.exit(3)
|
||||||
if nodeStates['state'] != "1":
|
if nodeStates['state'] != "1":
|
||||||
print "WARNING: Local node state is offline!"
|
print "WARNING: Local node state is offline!"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
elif nodeStates['rgmanager'] != "1":
|
elif nodeStates['rgmanager'] != "1":
|
||||||
print "CRITICAL: RGManager service not running on " + nodeStates['name'] + "!"
|
print "CRITICAL: RGManager service not running on " + nodeStates['name'] + "!"
|
||||||
sys.exit(1)
|
sys.exit(2)
|
||||||
else:
|
else:
|
||||||
print "OK: Cluster node " + nodeStates['name'] + " is online and cluster is quorate."
|
print "OK: Cluster node " + nodeStates['name'] + " is online and cluster is quorate."
|
||||||
sys.exit(0)
|
sys.exit(0)
|
Loading…
Reference in New Issue
Block a user