Running Monit v5 on OpenBSD

       324 words, 2 minutes

Quoting Monit’s website, “Monit is a free open source utility for managing and monitoring, processes, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.” I like it because it is much lighter than Nagios.

In the OpenBSD ports, it is available in version 4. But it is also provided as a binary archive from the website.

Here’s how to run Monit v5 on OpenBSD.


First of all, grab the tarball and install it in a dedicated location:

# ftp
# tar xzf monit-5.2.5-openbsd-x64.tar.gz -C /home/
# cd /home && mv monit-5.2.5 monit

Quite easy. Now, we need to solve some libs dependency issues:

# mkdir /home/monit/lib
# ln -s /usr/lib/ /home/monit/lib/
# ln -s /usr/lib/ /home/monit/lib/
# cat > /home/monit/bin/
LD_LIBRARY_PATH="/home/monit/lib" /home/monit/bin/monit -c /home/monit/conf/monitrc "$@"
# chmod 755 /home/monit/bin/

Configure the system to autostart Monit:

# vi /etc/rc.local
if [ -x /home/monit/bin/ ]; then
        echo -n ' monit'
        /home/monit/bin/ >/dev/null 2>&1

We are now ready to configure it.


We’ll use the configuration file shipped with the tarball:

# vi /home/monit/conf/monitrc
set daemon  120 with start delay 240

set logfile syslog facility log_daemon

set idfile /home/monit/
set statefile /home/monit/monit.state

set mailserver,
set alert

set httpd port 2812
        use address
        allow <i>login</i>:<i>password</i>

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

There are more things to do to monitor hosts and dæmons but I won’t describe it here.


To Read The Famous Manual, you can issue

# man -m /home/monit/man monit

That’s All Folks!
Next time, we’ll see how to monitor various services.