Created
January 6, 2017 07:38
-
-
Save nurhadimaulana2309/8ff2e3b1437071a0edc9eebd05a917d1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
1. INSTALL MONIT | |
sudo apt-get install monit | |
sudo nano /etc/monit/monitrc | |
monit | |
monit status | |
2. UNCOMMENT THIS SECTION FROM /etc/monit/monitrc | |
set httpd port 2812 | |
use address 12.34.56.789 # only accept connection from localhost | |
allow 0.0.0.0/0.0.0.0 # allow localhost to connect to the server and | |
allow admin:monit # require user 'admin' with password 'monit' | |
monit reload | |
3. EXAMPLE OF MONITORING NGINX | |
check process nginx with pidfile /run/nginx.pid | |
start program = "/etc/init.d/nginx start" | |
stop program = "/etc/init.d/nginx stop" | |
check process postgresql with pidfile /run/postgresql/9.4-main.pid | |
group database | |
start program = "/etc/init.d/postgresql start" | |
stop program = "/etc/init.d/postgresql stop" | |
check process redis-server with pidfile /run/redis_6379.pid | |
start program = "/etc/init.d/redis_6379 start" | |
stop program = "/etc/init.d/redis_6379 stop" | |
check process sidekiq | |
with pidfile /home/dev/apps/privateholidays_v2/shared/tmp/pids/sidekiq.pid | |
start program = "/bin/bash -l -c 'cd /home/dev/apps/privateholidays_v2/current && bundle exec sidekiq --index 0 --pidfile /home/dev/apps/privateholidays_v2/shared/tmp/pids/sidekiq.pid --environment production --logfile /home/dev/apps/privateholidays_v2/shared/log/sidekiq.log --daemon'" | |
stop program = "/bin/bash -l -c 'cd /home/dev/apps/privateholidays_v2/current && bundle exec sidekiqctl stop /home/dev/apps/privateholidays_v2/shared/tmp/pids/sidekiq.pid 10'" | |
if totalmem is greater than 512 MB for 3 cycles then restart | |
if 3 restarts within 5 cycles then timeout | |
* we might have to use sudo before all command | |
4. CHECK MONIT SYNTAX | |
monit -t | |
5. RUNNING ALL OF THE MONITORED PROGRAMS | |
monit start all | |
* references : http://richfisher.me/blog/2014/07/18/monit-configuration-for-rails/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment