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.
Installation
First of all, grab the tarball and install it in a dedicated location:
# ftp http://mmonit.com/monit/dist/binary/5.2.5/monit-5.2.5-openbsd-x64.tar.gz
# 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/libpthread.so.13.1 /home/monit/lib/libpthread.so.11.1
# ln -s /usr/lib/libc.so.58.0 /home/monit/lib/libc.so.50.1
# cat > /home/monit/bin/monit.sh
#!/bin/sh
LD_LIBRARY_PATH="/home/monit/lib" /home/monit/bin/monit -c /home/monit/conf/monitrc "$@"
^D
# chmod 755 /home/monit/bin/monit.sh
Configure the system to autostart Monit:
# vi /etc/rc.local
if [ -x /home/monit/bin/monit.sh ]; then
echo -n ' monit'
/home/monit/bin/monit.sh >/dev/null 2>&1
fi
We are now ready to configure it.
Configuration
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/monit.id
set statefile /home/monit/monit.state
set mailserver mail.tumfatig.net, smtp.free.fr
set alert joel@carnat.net
set httpd port 2812
use address bagheera.tumfatig.net
allow 10.0.0.0/24
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.
RTFM©
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.