├── README.rst ├── LICENSE.txt └── check_supv.py /README.rst: -------------------------------------------------------------------------------- 1 | Supervisord-Nagios-Plugin 2 | ------------------------- 3 | 4 | Instalation 5 | ----------- 6 | 7 | Copy the file check_supv.py to your Nagios/Icinga directory and make executable 8 | 9 | 10 | Configuration 11 | ------------- 12 | Set the supervisorctl status command, default is 13 | 14 | :: 15 | 16 | SUPERV_STAT_CHECK='sudo supervisorctl status' 17 | 18 | Please make sure nagios/icinga user can run the command without password 19 | 20 | Command 21 | ------- 22 | Run the command with the name of the supervisord process as it appears in ``supervisorctl status`` 23 | 24 | :: 25 | 26 | check_supv -p PROCESS_NAME 27 | 28 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Level Up ltd 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /check_supv.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | nagios plugin to monitor indivdual supervisor processes 4 | ------------------------------------------------------- 5 | 6 | usage 7 | 8 | :: 9 | 10 | check_supv -p PROCESS_NAME 11 | 12 | 13 | """ 14 | from optparse import OptionParser 15 | import os 16 | 17 | #nagios return codes 18 | UNKNOWN = -1 19 | OK = 0 20 | WARNING = 1 21 | CRITICAL = 2 22 | 23 | SUPERV_STAT_CHECK='sudo supervisorctl status' 24 | 25 | #supervisor states, map state to desired warning level 26 | supervisor_states = { 27 | 'STOPPED': OK, 28 | 'RUNNING': OK, 29 | 'STOPPING': WARNING, 30 | 'STARTING': WARNING, 31 | 'EXITED': CRITICAL, 32 | 'BACKOFF': CRITICAL, 33 | 'FATAL': CRITICAL, 34 | 'UNKNOWN': CRITICAL 35 | } 36 | 37 | def get_status(proc_name): 38 | try: 39 | status_output = os.popen('%s %s' % (SUPERV_STAT_CHECK, proc_name)).read() 40 | proc_status = status_output.split()[1] 41 | return (status_output, supervisor_states[proc_status]) 42 | except: 43 | print "CRITICAL: Could not get status of %s" % proc_name 44 | raise SystemExit, CRITICAL 45 | 46 | parser = OptionParser() 47 | parser.add_option('-p', '--processes-name', dest='proc_name', 48 | help="Name of process as it appears in supervisorctl status") 49 | parser.add_option('-v', '--verbose', dest='verbose', action='store_true', 50 | default=False) 51 | parser.add_option('-q', '--quiet', dest='verbose', action='store_false') 52 | 53 | options, args = parser.parse_args() 54 | 55 | output = get_status(options.proc_name) 56 | print output[0] 57 | raise SystemExit, output[1] 58 | --------------------------------------------------------------------------------