Skip to content

Instantly share code, notes, and snippets.

@joedougherty
Last active October 31, 2017 16:06
Show Gist options
  • Save joedougherty/7184c224e9407ae8b24a95a9d00f984e to your computer and use it in GitHub Desktop.
Save joedougherty/7184c224e9407ae8b24a95a9d00f984e to your computer and use it in GitHub Desktop.
supervisord_vs_monit
supervisord [supervisord.org]
=============================
* Set up jobs via a config file (.ini style)
Example:
--------
[program:forever]
command=/usr/bin/python /root/supervisoreval/bin/forever.py &
numprocs=1
autorestart=unexpected
exitcodes=0,2
autostart=false
Fill list of options here: https://supervisord.org/configuration.html#program-x-section-settings
* Runs jobs as child processes of `supervisord` process
* Pro: can restart processes almost instantaneously
* Con: if supervisord process dies, so do its processes, or they become orphaned processes
* Requires system Python of at least 2.6
* Documentation notes it won't run under Python 3, though this might not really be a concern for now -- really depends on
when RHEL moves to a Python 3 system version (probably not for a while)
* Installable via yum or pip
* Can view job statuses on command line using `supervisorctl`
* Has an optional web interface that allows an admin to start/stop/restart supervised jobs
* Can be installed as root or as a less privileged user
monit [mmonit.com]
=================
* Set up jobs via a config file (each job requires a pid file)
Example:
--------
check process forever with pidfile /var/run/forever.pid
start program = "/etc/init.d/forever start"
stop program = "/etc/init.d/forever stop"
Supports additional logic to determine what constitutes failure. Here's a more sophisticated example:
check process apache with pidfile /usr/local/apache/logs/httpd.pid
start program = "/etc/init.d/httpd start" with timeout 60 seconds
stop program = "/etc/init.d/httpd stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 200.0 MB for 5 cycles then restart
if children > 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if failed host www.tildeslash.com port 80 protocol http
and request "/somefile.html"
then restart
if failed port 443 type tcpssl protocol http
with timeout 15 seconds
then restart
See https://mmonit.com/monit/documentation/monit.html#EXISTENCE-TESTING for more details.
* Jobs are run on their own, not as child processes of monit.
* Polls jobs every two minutes by default so there will be some delay in services being brought back to life post-failure.
* Installable via yum
* Has a web interface that shows monitored jobs and allows start/stop/reload of services via the web (it's nice!)
* Should be installed by root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment