Skip to content

Instantly share code, notes, and snippets.

@ficus
Created October 6, 2016 15:48
Show Gist options
  • Save ficus/9be5f1d6b49747fe407300539f691056 to your computer and use it in GitHub Desktop.
Save ficus/9be5f1d6b49747fe407300539f691056 to your computer and use it in GitHub Desktop.
Monit configurations for common web server services.
set daemon 120 # check services at 2-minute intervals
with start delay 240 # optional: delay the first check by 4-minutes
set mailserver localhost
set alert [email protected]
# set alert [email protected] only on { timeout } # receive just service-
# # timeout alert
# system
check system $HOST
if loadavg (1min) > 5 then alert
if loadavg (5min) > 3 then alert
if memory usage > 75% then alert
#if memory usage > 80% for 4 cycles then alert
#if swap usage > 20% for 4 cycles then alert
if cpu usage (user) > 70% then alert
if cpu usage (system) > 30% then alert
if cpu usage (wait) > 20% then alert
# httpd
check process httpd with pidfile /var/run/httpd/httpd.pid
group www
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed port 80 protocol http then alert
if 3 restarts within 5 cycles then timeout
## php-fpm
check process php-fpm with pidfile /var/run/php-fpm/php-fpm.pid
group www
start program = "/etc/init.d/php-fpm start"
stop program = "/etc/init.d/php-fpm stop"
#if failed unixsocket /var/run/php-fpm/oas.sock ...
#if totalmem > 500 MB for 5 cycles then restart
#if children > 250 then restart
# mysql
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
group database
start program = "/etc/init.d/mysqld start"
stop program = "/etc/init.d/mysqld stop"
if failed host 127.0.0.1 port 3306 then restart
if 5 restarts within 5 cycles then timeout
# tomcat
check process tomcat with pidfile /var/run/tomcat6.pid
group birt
start program = "/etc/init.d/tomcat6 start"
stop program = "/etc/init.d/tomcat6 stop"
if failed port 8080 then alert
if failed port 8080 for 5 cycles then restart
# 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"
# if failed host 127.0.0.1 port 80 then restart
# if cpu is greater than 40% for 2 cycles then alert
# if cpu > 60% for 5 cycles then restart
# if 10 restarts within 10 cycles then timeout
# redis
#check process redis with pidfile /var/run/redis.pid
# start program = "/etc/init.d/redis-server start"
# stop program = "/etc/init.d/redis-server stop"
# group redis
#check file dump.rdb with path /var/lib/redis/dump.rdb
# if size > 100 MB then alert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment