Skip to content

Instantly share code, notes, and snippets.

@brianjlandau
Last active August 29, 2015 13:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianjlandau/10323155 to your computer and use it in GitHub Desktop.
Save brianjlandau/10323155 to your computer and use it in GitHub Desktop.
set daemon 120
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
set mailserver localhost
set mail-format { from: monit-noreply@viget.com }
set eventqueue
basedir /var/lib/monit/events
slots 100
set alert user@example.com
# Enable status reporting for CLI (i.e. `monit status`)
set httpd port 2812 and
use address localhost
allow localhost
include /etc/monit/conf.d/enabled/*.conf
check process mysql with pidfile /var/run/mysqld/mysqld.pid
start program = "/usr/sbin/service mysql start"
stop program = "/usr/sbin/service mysql stop"
if failed unixsocket /var/run/mysqld/mysqld.sock then restart
if changed pid then alert
if total memory > 50% for 5 cycles then restart
if total cpu > 80% for 5 cycles then restart
if 6 restarts within 26 cycles then alert
if 5 restarts within 5 cycles then timeout
check process nginx with pidfile /var/run/nginx.pid
start program = "/usr/sbin/service nginx start"
stop program = "/usr/sbin/service nginx stop"
if failed host localhost port 80 protocol http
and request '/' then alert
if changed pid then alert
if children > 25 then restart
if total memory > 60% for 5 cycles then restart
if total cpu > 80% for 5 cycles then restart
if 6 restarts within 26 cycles then alert
if 5 restarts within 5 cycles then timeout
check process sshd with pidfile /var/run/sshd.pid
start program = "/usr/sbin/service ssh start"
stop program = "/usr/sbin/service ssh stop"
if failed port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout
check system wing
if loadavg (1min) > 6 for 5 cycles then alert
if loadavg (5min) > 4 for 5 cycles then alert
if memory usage > 75% for 5 cycles then alert
if swap usage > 75% for 5 cycles then alert
if cpu usage (user) > 70% for 5 cycles then alert
if cpu usage (system) > 30% for 5 cycles then alert
if cpu usage (wait) > 20% for 5 cycles then alert
check filesystem root with path /
if space usage > 90% for 5 cycles then alert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment