30

I keep hearing about Nagios, a really powerful tool for monitoring servers. How do I install it?

3 Answers 3

47

First of all, I'm assuming that you're doing this on a stock, brand-spanking new install of 12.04. Nothing special happening here.

Install nagios:

sudo apt-get install -y nagios3

It will go through, and ask you about what mail server you want to use:

enter image description here

Pick one based upon your needs.

enter image description here

It will then ask you about the domain name you want to have email sent from. Again, fill that out based upon your needs.

It will ask you what password you want to use - put in a secure password. This is for the admin account nagiosadmin.

enter image description here

And then you'll need to verify your password.

Once the install is all done, you can head over to localhost/nagios3 (or whatever the IP address/domain name of the server you installed it on is) and you'll be asked to enter your password:

enter image description here

Once you've done that, you're in!

enter image description here

Little ugly, huh?

Nagios automatically adds in the 'localhost' to the config, and does load, current users, disk space, http and ssh checks.

enter image description here

Now there is one more thing we need to do before nagios is all ready - we need to have it accept external commands so we can acknowledge problems, add comments, etc.

To do that, we need to edit a few files. Start by opening /etc/nagios3/nagios.cfg with the following command:

sudo nano /etc/nagios3/nagios.cfg

Search for check_external_commands, and turn the check_external_commands=0 into check_external_commands=1.

Now, restart apache by running

sudo service apache2 restart

Not done yet! We need to edit /etc/group. There should be a line like this in there:

nagios:x:114

Change it to

nagios:x:114:www-data

Save and close this file.

Now, we need to edit the /var/lib/nagios3/rw files permission with:

sudo chmod g+x /var/lib/nagios3/rw

And then (because of how permissions work) we need to edit the permissions of the directory above that with:

sudo chmod g+x /var/lib/nagios3

Now, restart nagios with:

sudo service nagios3 restart

If you use Apache as your web server, restart that also:

sudo service apache2 restart

And you should be good to go! Happy monitoring!

To have alerts emailed to you, see this question and answer.

5
  • This install method does not work on a AMD64 server: Failed to fetch mirrors.gandi.net/ubuntu/pool/main/b/bind9/… 404 Not Found [Skip] I guess one need to compile from source... JPM
    – user91817
    Sep 21, 2012 at 7:39
  • @jpm: interesting. Nagios doesn't require BIND.
    – jrg
    Sep 21, 2012 at 10:40
  • 2
    perhaps sudo usermod -a -G nagios www-data is less error prone than editing /etc/group directly.
    – shabbychef
    Jan 14, 2014 at 18:39
  • Agree with @shabbychef. Also though, everything after "...there is one more thing we need to do before nagios is all ready" seems to not be necessary for standard functionality of Nagios. Why does one need to accept commands from a file by default, when the file /etc/nagios3/nagios.cfg actually states Nagios will *not* check for external commands, just to be on the cautious side?
    – user66001
    Aug 10, 2014 at 21:15
  • Because otherwise, many (if not most) nagios plugins and checks won't work otherwise.
    – jrg
    Aug 10, 2014 at 23:14
1

This howto on Linode.com is very detailed, and works with Nagios 3:

http://library.linode.com/server-monitoring/nagios/ubuntu-12.04-precise-pangolin

and here's a nice summary of how to monitor a website using Nagios 3:

http://ostatic.com/blog/monitoring-web-services-with-nagios

and here is another good example of configuring both Nagios and Apache, and configuring escalations:

http://bobcares.com/blog/?p=67

4
  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Nanne
    Feb 25, 2013 at 15:35
  • 1
    i completely agree, but I don't have time to copy it all in here nicely ;-) If someone wishes, they can copy it in here as another answer. The hard part was finding these concise summaries of how to do it! Thanks!
    – brad parks
    Feb 25, 2013 at 15:54
  • 1
    @bradparks for monitoring, our nagios tag here is becoming a fairly complete resource - I have documentation on how to email. For monitoring web services, that's more serverfault material, and almost considered common or basic knowledge.
    – jrg
    Feb 25, 2013 at 15:58
  • 1
    Hey! I think the question was quite general, and I think the majority of people would want to a) install nagios and b) setup/install a configuration for monitoring a website. So to me, I think this fits within the general nature of this question. Thanks!
    – brad parks
    Feb 25, 2013 at 16:28
-1

I recommend follow Nagios official Quickstart guide, which does not use apt-get, but download the source code, compile and then install.

This would ensure your Nagios is installed at /usr/local/nagios/

I find the advantage that Nagios installed at /usr/local/nagios/ when I try to install Nagios Service Check Acceptor, a add-on for Nagios.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .