

Stop program = "/etc/init.d/memcached stop"Ĭheck process mysqld with pidfile /var/run/mysqld/mysqld.pid Start program = "/etc/init.d/memcached start" Stop program = "/etc/init.d/gearman-job-server stop"Ĭheck process memcached with pidfile /var/run/memcached.pid Start program = "/etc/init.d/gearman-job-server start" Start program = "/etc/init.d/nginx start"Ĭheck process gearmand with pidfile /var/run/gearman/gearmand.pid If totalcpu > 20% for 5 cycles then restartĬheck process nginx with pidfile /var/run/nginx.pid If totalcpu > 20% for 2 cycles then alert Stop program = "/etc/init.d/apache2 stop"

Start program = "/etc/init.d/apache2 start" with timeout 20 seconds Here are the service monitoring lines from my config: check process apache with pidfile /var/run/apache2.pid On a 4 CPU machine, 25% represents a process consuming 100% of one CPU.įor the Apache monitor, the PID file is defined in /etc/apache2/envvars, and is usually /var/run/apache2.pid. If you monitor the totalcpu resource, note that is a percentage of all CPUs. Then monitor all the services running on that box. Monitor the machine itself: check system Make it a decent password, because the HTTP interface allows you to stop and start services. Set alert on the HTTP interface, allow access from anywhere, and require a username and password. Setup email alerts: set mailserver localhost Set Monit to check services every two minutes (120 seconds), and log to /var/log/daemon.log set daemon 120

The config file that comes with monit is well commented, but just in case here’s the breakdown. Here’s how to get it working on Ubuntu: Editing the config file sudo apt-get install monit It has an HTTP interface that shows you essential stats about the services you are monitoring. It can run a script of your choosing to attempt to fix the problem. When a file changes, hasn’t changed for a period of time, or grows beyond a certain size.When your machine has too high load average, memory consumption, or CPU usage.When a machine stops responding to network requests.Monit tells you if something goes wrong on your server, and tries to fix it. Februsoftware monit monitoring sysadmin ubuntu
