Last active
March 2, 2016 18:45
-
-
Save pedro108/d41480ad55ca92bd6374 to your computer and use it in GitHub Desktop.
Config files for Monit, specifically for Rails Applications using MySQL
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
httpd.monitrc | |
set httpd port 2815 and | |
allow #{client_ip} | |
allow admin:#{password} | |
mail.monitrc | |
set mailserver smtp.gmail.com port 587 username "#{smtp_user}" password "#{smtp_passw}" using tlsv1 | |
set mail-format { from: #{mail_from} } | |
# | |
# | |
## You can set alert recipients whom will receive alerts if/when a | |
## service defined in this file has errors. Alerts may be restricted on | |
## events by using a filter as in the second example below. | |
# | |
set alert #{mail_recipient} | |
system.httpd | |
## Check general system resources such as load average, cpu and memory | |
## usage. Each test specifies a resource, conditions and the action to be | |
## performed should a test fail. | |
# | |
check system #{server_name} | |
if memory usage > 90% for 3 cycles then alert | |
if cpu usage (system) > 50% for 3 cycles then alert | |
## Check filesystem permissions, uid, gid, space and inode usage. Other services, | |
## such as databases, may depend on this resource and an automatically graceful | |
## stop may be cascaded to them before the filesystem will become full and data | |
## lost. | |
# | |
check filesystem root with path /dev/xvda1 | |
if space usage > 90% for 3 cycles then alert | |
check filesystem mnt with path /dev/xvdf1 | |
if space usage > 90% for 3 cycles then alert | |
mysql.monitrc | |
check process mysql | |
with pidfile /var/run/mysqld/mysqld.pid | |
start program = "/usr/sbin/service mysql start" | |
stop program = "/usr/sbin/service mysql stop" | |
if failed host 127.0.0.1 port 3306 then alert | |
if totalmem > 500.0 MB for 5 cycles then alert | |
if cpu usage > 90% for 3 cycles then alert | |
if 5 restarts within 5 cycles then timeout | |
redis.monitrc | |
check process redis | |
with pidfile /var/run/redis/redis-server.pid | |
start program = "/usr/sbin/service redis-server start" | |
stop program = "/usr/sbin/service redis-server stop" | |
if failed host 127.0.0.1 port 6379 then restart | |
if totalmem > 200.0 MB for 5 cycles then restart | |
if cpu usage > 90% for 3 cycles then restart | |
if 5 restarts within 5 cycles then timeout | |
rails_app.monitrc | |
check process rails-app | |
with pidfile #{path_to_shared_app_directory}/pids/sidekiq.pid | |
start program = "/etc/monit/scripts/rails_bundle_exec.sh 'sidekiq -C config/sidekiq.yml'" | |
stop program = "/bin/kill `/bin/cat #{path_to_shared_app_directory}/pids/sidekiq.pid`" | |
if totalmem > 1024.0 MB for 5 cycles then alert | |
if cpu usage > 90% for 3 cycles then alert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment