Last active
October 3, 2021 03:48
-
-
Save georgiybykov/736b1671eb1dc15a1ab314dd547edffc to your computer and use it in GitHub Desktop.
nginx, unicorn, postgresql, redis, sidekiq, elasticsearch configs for monit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/monit/conf-enabled/qna.monit.rc | |
### Nginx ### | |
check process nginx with pidfile /run/nginx.pid | |
start program = "/usr/sbin/service nginx start" | |
stop program = "/usr/sbin/service nginx stop" | |
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 65.108.50.164 port 80 protocol http | |
then restart | |
if 3 restarts within 5 cycles then timeout | |
### Unicorn ### | |
check process unicorn | |
with pidfile "/home/deploy/qna/shared/tmp/pids/unicorn.pid" | |
start program = "/bin/su - deploy -c 'cd /home/deploy/qna/current && /home/deploy/.rvm/bin/rvm default do bundle exec unicorn -c /home/deploy/qna/current/config/unicorn/production.rb -E deployment -D'" | |
stop program = "bin/su - deploy -c 'kill -s QUIT `cat /home/deploy/qna/current/tmp/pids/unicorn.pid`'" | |
if cpu usage > 90% for 2 cycles then restart | |
if memory usage > 90% for 3 cycles then restart | |
if 5 restarts within 5 cycles then unmonitor | |
### Postgresql ### | |
check process postgresql | |
with pidfile /var/run/postgresql/12-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/sbin/service redis start" | |
stop program = "/usr/sbin/service redis stop" | |
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 | |
# with pidfile "/home/deploy/qna/shared/tmp/pids/sidekiq-0.pid" | |
with matching "sidekiq" | |
# start program = "/bin/su - deploy -c 'cd /home/deploy/qna/current && /home/deploy/.rvm/bin/rvm default do bundle exec sidekiq --index 0 --pidfile /home/deploy/qna/shared/tmp/pids/sidekiq-0.pid --environment producti> | |
# stop program = "/bin/su - deploy -c 'cd /home/deploy/qna/current && /home/deploy/.rvm/bin/rvm default do bundle exec sidekiqctl stop /home/deploy/qna/shared/tmp/pids/sidekiq-0.pid 10'" | |
start program = "/bin/su - deploy -c 'cd /home/deploy/qna/current && systemctl --user start sidekiq'" | |
stop program = "/bin/su - deploy -c 'cd /home/deploy/qna/current && 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 | |
### Elasticsearch ### | |
check process elasticsearch | |
# with matching "elasticsearch" | |
with pidfile "/var/run/elasticsearch/elasticsearch.pid" | |
start program = "/usr/sbin/service elasticsearch start" | |
stop program = "/usr/sbin/service elasticsearch stop" | |
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 unmonitor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A couple of interesting links about sidekiq with/and/for monit: