lundi 7 janvier 2008

Linux Nagios 2.6 Installation on Ubuntu 6.06 Linux Server

Nagios 2.6 Installation on Ubuntu 6.06 Linux Server

Nagios is an open source tool that monitors any device on a network that is IP addressable. I use it extensively on a daily basis at my workplace. It is easily configured to monitor a servers availability on the network from just simple TCP/IP ping requests, to more advanced service monitors such as http, dns, telnet, smtp and snmp. With additional plugins it can also monitor health status of devices such as CPU load, memory utilization and drive space consumption.This tutorial is created as a way for me to document the steps I took to install Nagios. There are many ways to install Nagios into a functional system, this just happens to be the way that I got it to work. If you are looking for an easy way to build your own Nagios server follow along and you’ll have your own running in no time.

Some assumptions are that you have basic Linux skills, and you have a freshly installed Ubuntu 6.06 LAMP server. Even though I’m going to give you a step-by-step walk through, a foundation of basic Linux knowledge would be preferred. If you need help installing Ubuntu Linux, take a look at my tutorial “Installing a Ubuntu 6.06 LAMP Server.”

(*note: Commands preceded by a “$” are run as a normal user and commands preceded by a “#” are run as root.)

System Requirements

The following software is required for a functional nagios server. This tutorial covers the installation of this software.

  • Apache2
  • GD Library
  • Nagios
  • Nagios Plugins
  • Basic Compilers


Starting from an unprivileged session, we need to change to root.

$ su


Enter your root password.


Now that we have root privileges, we need to install the “build-essential” package. This is really just a list of header files that assist with compiling software.

# apt-get install build-essential


Press “y” to confirm the installation.


Next, we need to install the GD Graphics Library.

# apt-get install libgd2-dev


Once again, press “y” to confirm the installation.


Next, we will install apache2.

# apt-get install apache2


Notice how it says apache2 is already the newest version? I started this tutorial with a fresh install of a LAMP server so apache2 was already installed and ready.


Now it’s time to download the nagios and nagios plugin package. I’m still in the home directory of my unprivileged account. This is where I want to download the files. In the command below, I used one of many download locations. If it doesn’t work for you another source can be found at

The following command will download nagios:

# wget


When the download is complete you will be returned to the command prompt.


The following command will download the nagios plugins:

# wget


Again, you are returned to the command prompt when the download finishes.


Do a directory listing to confirm that the files were downloaded.

# ls


Next, we use the “tar” command to unwrap and extract the source files of nagios.

# tar -xvf nagios-2.6.tar.gz


Let’s go into the newly extracted nagios folder.

# cd nagios-2.6


Let’s do a directory listing and see what we have.

# ls


Everything looks in order here.


Before we proceed, it’s time to create an account for the purpose of running the nagios scripts.

# adduser nagios


You will be asked to create a password. You can pick any password you like.


You will be asked to confirm that password.


Next you will be asked to enter some information pertaining to the new user. All of this information is optional.


Press “y” to confirm. After confirming the information, the user is created.


Next we need to make new home for our nagios installation. You can choose any location you like, however you will need to modify this tutorial to correspond to your installation. If this is your first install it may be best to use my suggested location.

# mkdir /usr/local/share/nagios


Now we need to make the nagios user the owner of our nagios install folder.

# chown nagios.nagios /usr/local/share/nagios/


Next, we need to create a group on our system that will be allowed to execute external commands from the web interface.

# /usr/sbin/groupadd nagcmd


Now, we’ll add the apache user and the nagios user to the nagcmd group.

# /usr/sbin/usermod -G nagcmd www-data


# /usr/sbin/usermod -G nagcmd nagios


Now we’re ready to prepare the installation scripts.

# ./configure --prefix=/usr/local/share/nagios --with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd


If the previous command comes back without reporting any errors you can run the following commands. If errors are reported, fix them and run “make clean” before running the previous command again.

# make all


# make install


The following command creates the initialization scripts for nagios.

# make install-init


The following command creates the folder permissions nagios needs.

# make install-commandmode


Create the sample configuration files.

# make install-config


Let’s move up one directory

# cd ..


A directory listing will show us the contents.

# ls


It’s time to extract the nagios plugin scripts.

# tar -xvf nagios-plugins-1.4.5.tar.gz


Next, we change to the nagios plugins folder.

# cd nagios-plugins-1.4.5


Now, we configure the plugin installation scripts.

# ./configure --prefix=/usr/local/share/nagios --with-cgiurl=/nagios/cgi-bin


If the previous command comes back without reporting any errors you can run the following commands. If errors are reported, fix them and run “make clean” before running the previous command again.

# make


Install the plugins.

# make install


# make install-root


Change directories up one level.

# cd ..


Now, it’s time to configure apache2 to serve up the nagios web interface.

# nano /etc/apache2/conf.d/nagios.conf


Type or past the following lines into the nano editor.

ScriptAlias /nagios/cgi-bin /usr/local/share/nagios/sbin

Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/share/nagios/etc/htpasswd.users
Require valid-user

Alias /nagios /usr/local/share/nagios/share

Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/share/nagios/etc/htpasswd.users
Require valid-user



Press “ctrl-x” to close the file. Press “y” to confirm saving when asked.


Use the default location of “/etc/apache2/conf.d/nagios.conf” for saving the file.


Reload apache to apply the new settings.

# /etc/init.d/apache2 restart


Create a password file for users authorized to access the nagios web interface. Here I’ll use “nagiosadmin” as the username.

(* The “-c” option tells htpasswd to create a new file. If you are adding multiple users don’t use the “-c” option or else you will continually create a new file, erasing the previous entries before them.)

# htpasswd -c /usr/local/share/nagios/etc/htpasswd.users nagiosadmin


Choose a secure password for the nagiosadmin account.


Confirm your password.



We’re finished using root access for now, time to logout.

# exit


We can now proceed to a computer with a web browser. In the address bar, type http:///nagios where is the IP address of the nagios server.


You should get an authentication prompt. You can enter your nagiosadmin user-name and password here and click ok.


What should appear next is your nagios server’s web interface.


What next?

At this point you have nagios installed. It isn’t useful yet because we haven’t configured it, nor have we started the nagios service on the server. The next step is to follow my guide for configuring nagios.

If you find any errors, typos, omissions or have any questions, please give me a shout. Thanks!


Jon aka cavern

Aucun commentaire: