Freshly delivered FOSS screencasts - every Friday.

#6 System Monitoring With Monit

Monit is a great open source tool for keeping track of your server or system. Monit can make sure daemons are running, permissions are correct, remote servers are responding, and much more.

In this episode we'll show you how to configure Monit to monitor our webserver, Apache HTTPD, starting it back up after a crash, and emailing us an alert.

If you'd like to try other monitoring utilities check out God, which uses Ruby for configuration, and Reconnoiter, which has some very robust features.

Uploaded on Oct 10, 2009 | 10:52 | Tags: Apache Monit Nginx

Click to Play

# uncomment include in monitrc
$ sudo nano /etc/monit/monitrc

include /etc/monit.d/*

# /etc/monit.d/localhost
set daemon 20
set logfile syslog facility log_daemon

set mailserver smtp.gmail.com port 587
        username "sender@address.com" password "password"
        using tlsv1
        with timeout 30 seconds

set alert recipient@address.com

set httpd port 2812 and
        use address localhost
        allow localhost
        allow 192.168.0.0/255.255.255.0
        allow admin:monit

check system localhost
        if loadavg (1min) > 4 then alert
        if loadavg (5min) > 2 then alert
        if memory usage > 75% then alert
        if cpu usage (user) > 70% then alert
        if cpu usage (system) > 30% then alert
        if cpu usage (wait) > 20% then alert


check process apache2 with pidfile /var/run/apache2.pid
        group www
        start program = "/etc/init.d/apache2 start"
        stop program  = "/etc/init.d/apache2 stop"
        if children > 250 then restart
        if loadavg(5min) greater than 10 for 8 cycles then stop
        if 3 restarts within 5 cycles then timeout


If you enjoyed this episode, be sure to check out the newest Technicast on Apache2. All purchases support FOSSCasts.