third-party-ci-tools/monitoring/nagios/checks/check_gearman.py
Patrick East 1bb3df6c6e Add some Nagios check scripts for some services involved with CI systems
These can be set up for nrpe or ssh checks on jenkins master nodes and
cover a few basic checks like:

- Ensuring a nodepool image age is not greater than some threshold
- Checking a specific job is registered in gearman
- Checking the health score for a specific jenkins job

All of these have tons of room for improvement and are just barebones
check scripts (closer to idiot checks) but can help detect some
common problems with 3rd party ci systems.

Change-Id: Ic6fbcfbdbf577646ebebf133b492f35535f37b00
2015-05-11 13:46:52 -07:00

29 lines
976 B
Python
Executable File

#!/usr/bin/env python
import argparse
import utils
def check_gearman_status(job_name):
"""Returns a tuple of exit code and message string
Exit codes are either 2 -> critical or 0 -> OK
There are no warnings with gearman job checker
"""
try:
gearadmin_status = utils.run_command_local('(echo status ; sleep 0.1) | netcat 127.0.0.1 4730 -w 1')
if job_name not in gearadmin_status:
return 2, 'Failed to find job registered with gearman!\nstatus:\n%s' % gearadmin_status
except Exception, e:
return 2, 'Failed to check gearman status' + e.message
return 0, job_name + ' is registered with gearman'
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Check gearman job status.')
parser.add_argument('--job', required=True, type=str, help='the job name to check for')
args = parser.parse_args()
code, message = check_gearman_status(args.job)
print message
exit(code)