Skip to content

Instantly share code, notes, and snippets.

@zxcvbnm4709
Created June 25, 2012 03:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zxcvbnm4709/2986254 to your computer and use it in GitHub Desktop.
Save zxcvbnm4709/2986254 to your computer and use it in GitHub Desktop.
Edit monit configuration file in /etc/monit/monitrc
set daemon 120
set logfile syslog facility log_daemon
set mailserver smtp.gmail.com port 587 username "user@domain.com" password "userpassword" using tlsv1,
with timeout 15 seconds
set eventqueue
basedir /var/monit
slots 1000
set mail-format { from: monit@mydomain.com }
set alert admin@domain.com
set httpd port 2812 and
allow admin:monit
check system localhost
if loadavg (1min) > 3 then alert
if loadavg (5min) > 2 then alert
if memory usage > 60% then alert
if cpu usage (user) > 70% then alert
if cpu usage (system) > 30% then alert
if cpu usage (wait) > 20% then alert
## nginx ##
check process nginx with pidfile /opt/nginx/logs/nginx.pid
start program = "/etc/init.d/nginx start"
stop program = "/etc/init.d/nginx stop"
group server
## mysql ##
check process mysql with pidfile /var/run/mysqld/mysqld.pid
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
group database
## redis ##
check process redis-server with pidfile /var/run/redis.pid
start program = "/usr/bin/redis-server /etc/redis.conf"
stop program = "/usr/bin/killall -9 redis-server"
group redis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment