Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ Please make sure nagios/icinga user can run the command without password

Command
-------
Run the command with the name of the supervisord process as it appears in ``supervisorctl status``

::

check_supv -p PROCESS_NAME
check_supv

31 changes: 22 additions & 9 deletions check_supv.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,24 @@
'UNKNOWN': CRITICAL
}

def get_status(proc_name):
def get_status():
try:
status_output = os.popen('%s %s' % (SUPERV_STAT_CHECK, proc_name)).read()
proc_status = status_output.split()[1]
return (status_output, supervisor_states[proc_status])
worst = OK
worst_lines = []
status_output = os.popen('%s' % (SUPERV_STAT_CHECK,)).readlines()
for line in status_output:
proc_status = line.split()[1]
cur_status = supervisor_states[proc_status]
if cur_status > worst:
worst = cur_status
worst_lines = []
worst_lines.append(line)
elif cur_status == worst:
worst_lines.append(line)
return (worst_lines, worst)
except:
print "CRITICAL: Could not get status of %s" % proc_name
raise SystemExit, CRITICAL
print "CRITICAL: Could not run %s" % (SUPERV_STAT_CHECK,)
raise SystemExit, UNKNOWN

parser = OptionParser()
parser.add_option('-p', '--processes-name', dest='proc_name',
Expand All @@ -52,6 +62,9 @@ def get_status(proc_name):

options, args = parser.parse_args()

output = get_status(options.proc_name)
print output[0]
raise SystemExit, output[1]
output = get_status()
if output[1] != 0:
print "Failures detected for "+(' '.join([x.split()[0] for x in output[0]]))
else:
print "All Services OK"
raise SystemExit, output[1]