Installing Nagiosby Oktay Altunergil
What is Nagios?
"Nagios is a system and network monitoring application. It watches hosts and services that you specify, alerting you when things go bad and when they get better" (from nagios.org). This is the same tool that used to be called NetSaint until recently. Although the NetSaint site is still up, all future development will be done on Nagios.
Nagios has an impressive list of features that include:
- Monitoring of network services such as HTTP, SMTP, SSH, Telnet, etc.
- Monitoring of server resources, such as disk usage and load averages.
- Real time notification of failures via email, pager, etc.
- A very informative Web interface that makes it very easy to identify problem hosts.
- Licensed under the GNU GPL.
Nagios runs on Unix and its variants and optionally requires a Web server to be installed (for the Web interface).
Installing and Configuring Nagios
Download the latest Nagios package and the latest Nagios plugins to a temporary location. For this article we will be using
root@ducati:~/tmp/nagios# ls nagios-1.0b5.tar.gz nagiosplug-1.3-beta1.tar.gz
First we will install the main Nagios application. Start by decompressing the
root@ducati:~/tmp/nagios# tar xfvz nagios-1.0b5.tar.gz
This will decompress the archive and we will end up with a
nagios-1.0b5 directory. (The filename and the name of the directory created will differ, depending on when and which version you download.) Go into this new directory:
root@ducati:~/tmp/nagios# cd nagios-1.0b5 root@ducati:~/tmp/nagios/nagios-1.0b5#
At this point, we need to decide where on our system we want to install Nagios. You can install Nagios anywhere, but the best approach to selecting the location is to stick with the default installation directory (
/usr/local/nagios), because the documentation always refers to this directory. This will make it easier to solve problems that we might have.
Create the directory where you would like to install Nagios.
root@ducati:~/tmp/nagios/nagios-1.0b5# mkdir /usr/local/nagios
At this point, we need to create a user and a group that our Nagios application will run as. You can use "root" for this purpose, but since it's not required, we might as well not use it, for better security. In order to make maintaining Nagios easier, we will dedicate a new username and group to it. The user and the group that we will create are both called "nagios."
root@ducati:~/tmp/nagios/nagios-1.0b5# useradd nagios
If you don't have the
useradd command on your system, try the
adduser command. On some systems,
adduser is an interactive command that expects you to answer a few questions before creating the account. Please refer to the man page for the command you're using for more information.
root@ducati:~/tmp/nagios/nagios-1.0b5# groupadd nagios
On some systems,
adduser will create the matching group; on other systems you will need to edit the
/etc/group file to add the group by hand. Please refer to the documentation on your system for more information.
Once we have created the user and the group, we can now start the actual installation process. First we need to specify some parameters and create the Makefile that will be used to compile and install the software.
Type the following script on a single line without line breaks:
root@ducati:~/tmp/nagios/nagios-1.0b5# ./configure --prefix=/usr/local/nagios --with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios/ --with-nagios-user=nagios --with-nagios-grp=nagios
If you have opted to install Nagios in
/usr/local/nagios and the user and group you have created are both "nagios," you might as well just run
./configure with no parameters, since the above values are the default values configure will assume. You can also run
configure --help to see a lot more options you can use.
Once configure completes, it will display a summary of all parameters that were used during the configuration. Make sure everything is OK, and run
configure again with the correct options, if necessary.
There's also a very high chance of getting a warning about the lack of GD libraries from Boutell. You can go back and install GD if it's not installed. If you already have it on your system and
configure can't find it, you can use the
--with-gd-inc options to specify the exact directories where your
gd include and library files are located. If, after trying all of these, you're still getting the warning about GD, the configuration script suggests just giving up on using the components that require GD and living with it. I believe this is a good approach if you're installing Nagios for the first time. The GD library is only used in a few CGIs that create dynamic images from the service statistics. The application is still very useful without these graphics. You can always go back and reinstall the application when you're more comfortable with GD and Nagios.
Now it's time to actually compile the software. This is done as follows (if you're not logged in as "root," you need to switch to the "root" user at this point):
root@ducati:~/tmp/nagios/nagios-1.0b5# make all
This step will take a while to complete, especially on a slower machine. If there were no problems during the compilation, you will receive a "Compile finished" notification. Right now, all of our software is compiled and ready to be installed to the directories that we have specified in
We will run three install commands to install various components in place. First we need to install the main program files and directories in
/usr/local/nagios. This step is required.
root@ducati:~/tmp/nagios/nagios-1.0b5# make install
Now, optionally, we can install the startup script so that Nagios starts automatically at boot time. This script will also allow us to start, stop, restart, and reload Nagios conveniently. This is accomplished as follows:
root@ducati:~/tmp/nagios/nagios-1.0b5# make install-init
On my system (which is running Slackware 8.0), this installs a
nagios script in
/etc/rc.d. Depending on your distribution, this file might also be installed in
/etc/rc.d/init.d/. The configurator should take care of this. On my system, I have renamed this file to
rc.nagios, which conforms better to the naming structure for Slackware. On FreeBSD, the file would need to live in
/usr/local/etc/rc.d and be renamed
nagios.sh for it to work properly.
If you take a look into the
/usr/local/nagios directory right now, you will see that there are four directories.
root@ducati:~/tmp/nagios/nagios-1.0b5# ls /usr/local/nagios/ bin sbin share var
bin directory contains a single file,
nagios, that is the core of the package. This application does the actual monitoring. The
sbin directory contains the CGI scripts that will be used in the Web-based interface. Inside of the
share directory, you can find the HTML files and documentation. Finally, the
var directory is where Nagios will be storing its information, once it starts running.
In order to be able to use Nagios, we need a couple of configuration files. These files go into the
etc directory, which will be created when you run the following:
root@ducati:~/tmp/nagios/nagios-1.0b5# make install-config
This command also creates a sample copy of each required configuration file and puts them into the
Pages: 1, 2