Skip to content

Instantly share code, notes, and snippets.

@Azmandius21
Last active February 9, 2024 19:32
Show Gist options
  • Save Azmandius21/547714fc25c26730179dc7cab487657d to your computer and use it in GitHub Desktop.
Save Azmandius21/547714fc25c26730179dc7cab487657d to your computer and use it in GitHub Desktop.
Config file for Monit service
### Nginx ###
check process nginx with pidfile /run/nginx.pid
start program = "/usr/bin/systemctl start nginx.service"
stop program = "/usr/bin/systemctl stop nginx.service"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 79.174.95.43 port 80 protocol http
then restart
if 3 restarts within 5 cycles then timeout
### Unicorn ###
check process unicorn with pidfile /home/deployer/qna/shared/tmp/pids/unicorn.pid
start program = "/usr/bin/systemctl start unicorn.service"
stop program = "/usr/bin/systemctl stop unicorn.service"
if cpu > 90% for 2 cycles then restart
if memory usage > 90% for 3 cycles then restart
if 5 restarts within 5 cycles then timeout
### Postgresql ###
check process postgresql
with pidfile /var/run/postgresql/14-main.pid
start program = "/usr/sbin/service postgresql start"
stop program = "/usr/sbin/service postgresql stop"
if failed host localhost port 5432 protocol pgsql then restart
if cpu > 80% then restart
if memory usage > 80% for 2 cycles then restart
if 5 restarts within 5 cycles then timeout
### Redis ###
check process redis-server
with pidfile "/var/run/redis/redis-server.pid"
start program = "/usr/bin/systemctl start redis-server.service"
stop program = "usr/bin/systemctl stop redis-server.service"
if totalmem > 100 Mb then alert
if children > 255 for 5 cycles then stop
if cpu usage > 95% for 3 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 127.0.0.1 port 6379 then restart
if 5 restarts within 5 cycles then timeout
### Sidekiq ###
check process sidekiq MATCHING sidekiq
start program = "bin/su deployer -c '/usr/bin/systemctl --user start sidekiq'"
stop program = "bin/su deployer -c '/usr/bin/systemctl --user stop sidekiq'"
if cpu > 80% then restart
if memory usage > 80% for 2 cycles then restart
if 3 restarts within 3 cycles then timeout
### Sphinx ###
check process sphixnsearch
with pidfile "/home/deployer/qna/shared/tmp/searchd.pid"
start program = "/bin/su deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec rake ts:start RAILS_EN>
stop program = "/bin/su deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec rake ts:stop RAILS_ENV=>
if cpu usage > 80% for 2 cycles then restart
if memory usage > 80% for 4 cycles then restart
if 3 restarts within 3 cycles then timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment