The Ubuntu package for monit is way out of date on Hardy (8.04 LTS): the package is at version 4.8.1 when the latest version of monit is 5.0.1. Even the Jaunty package is only at version 4.10. There are additional features such as remote mail servers that you cannot use on 4.8.1. Another issue with using the old monit package on Ubuntu is that it is out of sync with the monit documentation.
This post will show you how you can install monit from the latest source on Ubuntu Hardy.
First, we’ll use a dirty trick to obtain some Ubuntu init scripts for monit: we’ll install monit using apt-get and then remove it. In the process, the monit init scripts will not be deleted and we will be able to use them with our fresh install of monit from source.
sudo apt-get install monit
After installing, make sure that the following files are present: /etc/init.d/monit, /etc/default/monit and /etc/monit/monitrc (that’s the whole reason why we are installing monit from the package after all. Once we’ve got that file, we can simply remove the package:
sudo apt-get remove monit
Cool now we have an init script and our config files. We will modify them later to work with our new monit install
Before downloading the monit source, let’s install a few dependencies
sudo apt-get install libssl-dev bison flex
Now, get the latest monit package from their download page and untar it:
wget http://mmonit.com/monit/dist/monit-5.0.1.tar.gz
tar xzvf monit-5.0.1.tar.gz
cd monit-5.0.1
OK. You are not ready to build and install the source
./configure
Watch the output and if everything went smoothly, then:
make
sudo make install
At this point you should have the latest and greatest version of monit installed. Let’s verify that:
monit -V
It should print:
This is monit version 5.0.1
Copyright (C) 2000-2009 by Tildeslash Ltd. All Rights Reserved.
Almost there, we just need to make a couple of small changes to the init script. Find the following lines in /etc/init.d/monit (should be way on top):
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/monit
… and replace them with:
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DAEMON=/usr/local/bin/monit
Now open up /etc/default/monit and find startup=0. Replace that with startup=1 and save the file.
You can now modify your config file located at /etc/monit/monitrc as you see fit. Once you are done, verify that the config file is OK:
sudo monit -c /etc/monit/monitrc -t
If the syntax of your file is ok, you are ready to start monit:
sudo /etc/init.d/monit start
That’s It I hope this helped!