Add monitoring basics
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
set daemon 30
|
||||
|
||||
set logfile /var/log/monit.log
|
||||
set idfile /var/lib/monit/id
|
||||
set statefile /var/lib/monit/state
|
||||
|
||||
set eventqueue
|
||||
basedir /var/lib/monit/events
|
||||
slots 100
|
||||
|
||||
# set mailserver smtp.gmail.com port 587
|
||||
# username "foo@example.com" password "secret"
|
||||
# using tlsv1
|
||||
# with timeout 30 seconds
|
||||
|
||||
set alert bterkuile+uflows-server-alert@gmail.com
|
||||
|
||||
set httpd port 2812
|
||||
allow admin:"Monit22Secret"
|
||||
|
||||
check system blog_server
|
||||
if loadavg(5min) > 2 for 2 cycles then alert
|
||||
if memory > 75% for 2 cycles then alert
|
||||
if cpu(user) > 75% for 2 cycles then alert
|
||||
|
||||
include /etc/monit/conf.d/*
|
||||
@@ -0,0 +1,5 @@
|
||||
check process nginx with pidfile /var/run/nginx.pid
|
||||
start program = "/etc/init.d/nginx start"
|
||||
stop program = "/etc/init.d/nginx stop"
|
||||
if children > 250 then restart
|
||||
if 5 restarts within 5 cycles then timeout
|
||||
@@ -0,0 +1,5 @@
|
||||
check process postgresql with pidfile <%= postgresql_pid %>
|
||||
start program = "/etc/init.d/postgresql start"
|
||||
stop program = "/etc/init.d/postgresql stop"
|
||||
if failed host localhost port 5432 protocol pgsql then restart
|
||||
if 5 restarts within 5 cycles then timeout
|
||||
@@ -0,0 +1,8 @@
|
||||
after_fork do |server, worker|
|
||||
# Start up the database connection again in the worker
|
||||
if defined?(ActiveRecord::Base)
|
||||
ActiveRecord::Base.establish_connection
|
||||
end
|
||||
child_pid = server.config[:pid].sub(".pid", ".#{worker.nr}.pid")
|
||||
system("echo #{Process.pid} > #{child_pid}")
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
check process <%= application %>_unicorn with pidfile <%= unicorn_pid %>
|
||||
start program = "/etc/init.d/unicorn_<%= application %> start"
|
||||
stop program = "/etc/init.d/unicorn_<%= application %> stop"
|
||||
|
||||
<% unicorn_workers.times do |n| %>
|
||||
<% pid = unicorn_pid.sub(".pid", ".#{n}.pid") %>
|
||||
check process <%= application %>_unicorn_worker_<%= n %> with pidfile <%= pid %>
|
||||
start program = "/bin/true"
|
||||
stop program = "/usr/bin/test -s <%= pid %> && /bin/kill -QUIT `cat <%= pid %>`"
|
||||
if mem > 200.0 MB for 1 cycles then restart
|
||||
if cpu > 50% for 3 cycles then restart
|
||||
if 5 restarts within 5 cycles then timeout
|
||||
alert foo@example.com only on { pid }
|
||||
if changed pid 2 times within 60 cycles then alert
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user