Install monit from source on Ubuntu

5 05 2009

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!

Advertisement

Actions

Information

10 responses

5 05 2009
Install monit from source on Ubuntu | Ubuntu-News - Your one stop for news about Ubuntu

[...] post will show you how you can install monit from the latest source on Ubuntu Hardy. More here The Ubuntu package for monit is way out of date on Hardy (8.04 LTS): the package is at version [...]

6 05 2009
ubuntuverse

thanks! exactly what I was looking for.

24 05 2009
ber

thanks luc!

4 06 2009
Rodrigo

Also exactly what I needed! Thanks a lot! =)

9 08 2009
Brian Armstrong

Nice writeup thanks!

It didn’t quite work out of the box for me, so I ended up setting

set logfile /var/log/monit.log

in /etc/monit/monitrc

Then I was able to see error messages . It was dying on this:
monit: Cannot open the monit state file ‘/var/lib/monit/monit.state’ — No such file or directory

I had to create the directory and file manually as root, then it started working. Strange. But at least it’s working now.

Thanks!
Brian

Btw, I also was seeing these error message

Cannot open the monit state file ‘/var/lib/monit/monit.state’ — No such file or directory

9 08 2009
Brian Armstrong

Also, I couldn’t figure out why my “set daemon 5″ was being ignored in
/etc/init.d/monit

Turns out this gets overridden when you start the service as a daemon with
sudo /etc/init.d/monit start

open /etc/init.d/monit and you can see the CHECK_INTERVALS setting at the top (defaults to every 3 minutes).

Hope it helps someone!

15 09 2009
Daniel

Thanks! VERY helpful and clear written.

3 11 2009
Paul

Thanks for the guide. Very useful. I had the same ‘Cannot open the monit state file ‘/var/lib/monit/monit.state’ — No such file or directory’ problem but creating the directory as root made it go away.

Paul

14 03 2011
Martin

Thanks Paul,
I’ve installed rpmforge monit-5.2.4 and had same problem on CentOS 5.5
For me this:
#mkdir /var/monit
solve the problem

Martin

27 06 2011
Didier

# monit -t
monit: Cannot find the control file at ~/.monitrc, /etc/monitrc, /usr/local/etc/monitrc, /usr/local/etc/monitrc or at ./monitrc

FIXED BY :
# ln -s /etc/monit/monitrc /etc/monitrc

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.