Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Little additions to check_rhcs (mostly safeguards) #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions check_rhcs/check_rhcs → check_rhcs/check_rhcs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/env python

#
# Gather the cluster state and the current node state
#
# Output example:
Expand All @@ -23,6 +21,14 @@
#</clustat>
#
# 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 os
Expand Down Expand Up @@ -112,6 +118,7 @@ def main():
sys.exit(2)

check_suspend = False
typeCheck = None
for o, a in opts:
if o in ('-c', '--cluster'):
typeCheck = 'cluster'
Expand All @@ -124,6 +131,10 @@ def main():
usage()
sys.exit()

if typeCheck == None:
usage()
sys.exit()

try:
clustatOutput = os.popen('/usr/sbin/clustat -fx')
dom = xml.dom.minidom.parse(clustatOutput)
Expand All @@ -133,7 +144,7 @@ def main():
if typeCheck == 'cluster':

# 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)
qState = getQuorumState(dom)

Expand All @@ -145,15 +156,18 @@ def main():
# 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.
nodeStates = getLocalNodeState(dom)
if nodeStates['state'] != "1":
print "WARNING: Local node state is offline!"
sys.exit(1)
elif nodeStates['rgmanager'] != "1":
print "CRITICAL: RGManager service not running on " + nodeStates['name'] + "!"
sys.exit(1)
else:
print "OK: Cluster node " + nodeStates['name'] + " is online and cluster is quorate."
sys.exit(0)
if nodeStates == {}:
print "UNKNOWN: Local node informations couldn't be found!"
sys.exit(3)
if nodeStates['state'] != "1":
print "WARNING: Local node state is offline!"
sys.exit(1)
elif nodeStates['rgmanager'] != "1":
print "CRITICAL: RGManager service not running on " + nodeStates['name'] + "!"
sys.exit(2)
else:
print "OK: Cluster node " + nodeStates['name'] + " is online and cluster is quorate."
sys.exit(0)

elif typeCheck == 'service':
serviceState = getServiceState(dom, serviceName)
Expand Down