Are you one of those special geeks that think there is never TMI (too much information)? If that describes you then Nagios is the monitor for you. Once installed, Nagios will keep you busy with more information about your system than you ever thought possible. But it's not just a matter of running apt-get install nagios. No, there's more to the installation than that.
In this article you will see how to install Nagios on a working Ubuntu Server installation. The release I used was 9.04, but you should be able to use 8.04 just as easily.
You want features? Nagios is full of them. Nagios can monitor your entire network, you can handle problem remediation, you can plan network downtime, you can watch hosts, systems, services, applications..there's very little you can't do with Nagios.
But let's think about this installation. The best (and really only good) way to install Nagios is from source. This means you are going to have to do some compliation. Don't worry, it's not hard...when you have a step-by-step guide that is.
Before you start
If you are using, as I did, a Ubuntu server installation, you will need to install a few tools first. So from the command line (on your Ubuntu server) issue the following commands:
sudo apt-get install php5-gd
sudo apt-get install gcc
sudo apt-get install make
The above commands will install the tools you need in order to get Nagios installed. If you don't install the above, you won't be able to complete the installation.
Installing Nagios - preflight
Before you actually run the installation you will need to take care of some user/group accounting first.
Create the user nagios:
sudo useradd -m nagios
Give the nagios user a password:
sudo passwd nagios
NOTE: You will have to enter the new password twice for the above command.
Create the group nagios:
sudo groupadd nagios
Add the user nagios to the group nagios:
sudo usermod -G nagios nagios
Create the group nagcmd:
sudo groupadd nagcmd
Add the user nagios to the group nagcmd:
sudo usermod -a -G nagcmd nagios
Add the Apache user to the group nagcmd:
sudo usermod -a -G nagcmd www-data
Installing Nagios and Nagios Plugins
The first thing to do is to download the files you need. Issue the commands:
to download the files you need.
Untar the Nagios file with:
tar xvzf nagios-3.0.6.tar.gz
Change into the newly created Nagios directory with the command:
Now run the configure script using the nagcmd defined as the command group with the command:
sudo ./configure --with-command-group=nagcmd
Time to compile:
sudo make all
Time to install everything:
Almost ready to finalize the installation of Nagios (before moving on to installing the plugins.) There is one simple configuration to take care of (for the basic installation). Open up the /usr/local/nagios/etc/objects/contacts.cfg file and add your email address as the contact email address. That's the only configuration to change for now.
Configuring for the Web interface
There are just a few commands to run to configure the Web interface:
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
The final command above simply restarts Apache.
Install the plugins
Before you log into your Nagios installation you have to install your plugins first. Change to the directory you downloaded the Nagios files to and untar the plugins file:
tar xvzf nagios-plugins-1.4.11.tar.gz
Now change into the newly created directory:
Compile the plugins with the command:
sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios
Now install the plugins with the following commands:
Fire it up!
Of course you want to make sure Nagios starts any time the system is restarted. Do this with the command:
sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
And finally, before you start up Nagios, make sure there are no errors with the command:
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If you see no errors reported, it's time to start it up. Issue the command:
sudo /etc/init.d/nagios start
Nagios is ready to go. Point your browser to:
You should be ready to enjoy all that is Nagios. Congratulations.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.