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

Installation

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

$ su

nagios_2-6_installation_on_ubuntu_6-06_linux4.png

Enter your root password.

nagios_2-6_installation_on_ubuntu_6-06_linux5.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux7.png

Press “y” to confirm the installation.

nagios_2-6_installation_on_ubuntu_6-06_linux9.png

Next, we need to install the GD Graphics Library.

# apt-get install libgd2-dev

nagios_2-6_installation_on_ubuntu_6-06_linux11.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux13.png

Next, we will install apache2.

# apt-get install apache2

nagios_2-6_installation_on_ubuntu_6-06_linux15.png

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.

nagios_2-6_installation_on_ubuntu_6-06_linux16.png

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 nagios.com.

The following command will download nagios:

# wget http://umn.dl.sourceforge.net/sourceforge/nagios/nagios-2.6.tar.gz

nagios_2-6_installation_on_ubuntu_6-06_linux17.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux18.png

The following command will download the nagios plugins:

# wget http://umn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.5.tar.gz

nagios_2-6_installation_on_ubuntu_6-06_linux19.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux20.png

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

# ls

nagios_2-6_installation_on_ubuntu_6-06_linux22.png

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

# tar -xvf nagios-2.6.tar.gz

nagios_2-6_installation_on_ubuntu_6-06_linux23.png

Let’s go into the newly extracted nagios folder.

# cd nagios-2.6

nagios_2-6_installation_on_ubuntu_6-06_linux25.png

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

# ls

nagios_2-6_installation_on_ubuntu_6-06_linux27.png

Everything looks in order here.

nagios_2-6_installation_on_ubuntu_6-06_linux28.png

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

# adduser nagios

nagios_2-6_installation_on_ubuntu_6-06_linux29.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux30.png

You will be asked to confirm that password.

nagios_2-6_installation_on_ubuntu_6-06_linux31.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux32.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux33.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux35.png

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

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

nagios_2-6_installation_on_ubuntu_6-06_linux37.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux39.png

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

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

nagios_2-6_installation_on_ubuntu_6-06_linux41.png

# /usr/sbin/usermod -G nagcmd nagios

nagios_2-6_installation_on_ubuntu_6-06_linux43.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux45.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux47.png

# make install

nagios_2-6_installation_on_ubuntu_6-06_linux49.png

The following command creates the initialization scripts for nagios.

# make install-init

nagios_2-6_installation_on_ubuntu_6-06_linux51.png

The following command creates the folder permissions nagios needs.

# make install-commandmode

nagios_2-6_installation_on_ubuntu_6-06_linux53.png

Create the sample configuration files.

# make install-config

nagios_2-6_installation_on_ubuntu_6-06_linux55.png

Let’s move up one directory

# cd ..

nagios_2-6_installation_on_ubuntu_6-06_linux57.png

A directory listing will show us the contents.

# ls

nagios_2-6_installation_on_ubuntu_6-06_linux60.png

It’s time to extract the nagios plugin scripts.

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

nagios_2-6_installation_on_ubuntu_6-06_linux61.png

Next, we change to the nagios plugins folder.

# cd nagios-plugins-1.4.5

nagios_2-6_installation_on_ubuntu_6-06_linux63.png

Now, we configure the plugin installation scripts.

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

nagios_2-6_installation_on_ubuntu_6-06_linux65.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux67.png

Install the plugins.

# make install

nagios_2-6_installation_on_ubuntu_6-06_linux69.png

# make install-root

nagios_2-6_installation_on_ubuntu_6-06_linux71.png

Change directories up one level.

# cd ..

nagios_2-6_installation_on_ubuntu_6-06_linux73.png

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

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

nagios_2-6_installation_on_ubuntu_6-06_linux76.png

Type or past the following lines into the nano editor.

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

<Directory "/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
</Directory>

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

<Directory "/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
</Directory>

nagios_2-6_installation_on_ubuntu_6-06_linux78.png

nagios_2-6_installation_on_ubuntu_6-06_linux79.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux80.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux81.png

Reload apache to apply the new settings.

# /etc/init.d/apache2 restart

nagios_2-6_installation_on_ubuntu_6-06_linux83.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux85.png

Choose a secure password for the nagiosadmin account.

nagios_2-6_installation_on_ubuntu_6-06_linux86.png

Confirm your password.

nagios_2-6_installation_on_ubuntu_6-06_linux87.png

nagios_2-6_installation_on_ubuntu_6-06_linux88.png

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

# exit

nagios_2-6_installation_on_ubuntu_6-06_linux89.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux93.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux95.png

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

nagios_2-6_installation_on_ubuntu_6-06_linux96.png

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!

Credits

Jon aka cavern
http://ubuntuforums.org/showthread.php?t=223498

Tags: , , , , , ,

39 Comments so far »

  1. Don said,

    Wrote on March 31, 2007 @ 7:19 am

    Great article! I installed Nagios 2.8 with it and didn’t seem to have any problems. You da man!

  2. Netwerkdude said,

    Wrote on April 7, 2007 @ 8:23 pm

    EXCELLENT Article!!! thanks so much for this write up. How long until the configuration article?

  3. Mark said,

    Wrote on April 9, 2007 @ 9:15 am

    Thanks guys for the kind words! I’m still working on putting the finishing touches on the configuration guide. I have to admit that I ran into some errors writing the guide and I had to figure out what I did wrong. I’m sure you can understand that is the nature of tech business. I did a horrible job at documenting my initial install of nagios that I had to re-learn it from scratch.

  4. Mark said,

    Wrote on April 10, 2007 @ 1:48 pm

    Small update:

    The follow-up configuration tutorial is coming along. There are 90+ screen shots that I’m weeding through and cropping now.

  5. Baron said,

    Wrote on April 20, 2007 @ 5:55 am

    Great tutorial and I look forward to the rest!

  6. Randall said,

    Wrote on April 22, 2007 @ 2:27 pm

    Hello,

    I can’t tell you how helpful this has been. My background is Windows/WhatsUp and the documentation from the Nagios website doesn’t cut it for a newbie. After several attempts I am having issues while trying to install plugins-1.4.8. I was able to work through the nagios-2.9 install but the plugins install errors when I run make. It runs fine until the end and then errors after the line:

    creating symbolic link ‘check_ftp’ to ‘check_tcp’: Operation not permitted

    I have no idea what this means or what I’m supposed to do to resolve it.

    Any suggestions you might have would be greatly appreciated.

    Thank you for the efforts you have made.

    Randall

  7. George said,

    Wrote on April 25, 2007 @ 5:59 am

    Great! my first task on a Linux server was to get nagios installed, and with your guide it worked on the first time. Many thanks. How is the configuration article coming along?

  8. Mark said,

    Wrote on April 26, 2007 @ 12:27 pm

    @ Randall

    The only idea I have about the symbolic link creation error is that you may be using a filesystem that doesn’t support them such as VFAT or FAT32. Make sure your system is using a compatible filesystem like ext3 or such.

    @ everyone

    The next part of the guide is complete. I just have to get it uploaded.

  9. Nick L said,

    Wrote on May 2, 2007 @ 12:04 am

    Howdy,
    I got through the install with no reported errors and when I try to access the web server from my laptop I get a 403 forbidden error. What’s up with that? I’m not that skilled with Linux or web servers, but if this were a Windows server I’d start checking permissions.
    Thanks for any help. Great tutorial regardless!

  10. Gabriele said,

    Wrote on May 4, 2007 @ 5:29 am

    Great article! Thank you!

  11. Patrick said,

    Wrote on May 10, 2007 @ 6:41 am

    Hi! Great article, it really helped me out with getting this beast working :P

    The only problem I have here is that when I click on status map or histogram ou the web interface I get this error: ” The requested URL /nagios/cgi-bin/statusmap.cgi was not found on this server.”

    I tried recompiling, changing a few option with ./configure but nothing worked. I also noticed that the missing cgi were not even compiled :-|

    I also searched a few spot on the net, but didnt find a working solution.

    I am using Nagios 2.9, Plugin 1.4.7, and Debian Etch. I don’t know if this information is important, but this server is a virtual machine.

    If you have a hint, that would be wonderful!

    Thanks!

    Patrick

  12. Baron said,

    Wrote on May 11, 2007 @ 8:16 am

    Hey Mark any ETA on the config? Last I saw you were uploading it. I am looking forward to the rest.

  13. Paulo said,

    Wrote on May 14, 2007 @ 9:26 am

    Thanks a lot for your help. Just like George, my first task on Linux on my job was to install Nagios without using a GUI and also without any previous knowledge of Linux either graphic or command line, so this tutorial with another one regarding LAMP helped me a lot. I’m eager to read the second part of this since I’m sure that it will also help me. Thank you!

  14. one depressed Guy said,

    Wrote on May 15, 2007 @ 8:08 am

    Great job on the tutorial i install nagios without a prob but now i cant config him i dont have any knowledge on linux and im just so tired of trying im becoming depressed :P

  15. Rob said,

    Wrote on May 26, 2007 @ 1:27 pm

    This is an excellent guide. Thanks. I was wondering if you have been able to progress the configuration guide? Cheers, Rob.

  16. Rob said,

    Wrote on May 29, 2007 @ 11:06 pm

    Maybe even an uncompleted guide?

  17. Mark said,

    Wrote on May 30, 2007 @ 7:43 am

    Sorry for the delay guys… Life happens to get in the way sometimes. I’ll spare the details but I had to put off a few hobbies, like this site, for a while.

    I’m working on the guide today. I don’t know if it will be ready but you can get a sneak preview of it by using this url: http://www.nukesilo.com/?p=460&preview=true

  18. Nagios 2.6 Basic Configuration « NukeSilo.com said,

    Wrote on May 30, 2007 @ 2:25 pm

    […] Before nagios can be configured it needs to be installed. That documentation can be found here: Nagios 2.6 Installation on Ubuntu 6.06 Linux […]

  19. LeoCombes said,

    Wrote on June 25, 2007 @ 1:54 pm

    EX-CE-LLE-NT!!

    In 10 min nagios work!!
    Very well explained!!

    Tanks!

  20. Anushila said,

    Wrote on July 4, 2007 @ 3:22 am

    thank u!!really helped
    :)

  21. 7echno7im said,

    Wrote on July 23, 2007 @ 10:19 am

    flawless victory on the install, lets see if the configuration goes just as smooth. I used Ubuntu Server 7.04 with Nagios 2.9 and 1.4.9 of the plugins. Nice guide. I am going to surely review this on my site, www.techtronic.us as soon as I get some time.

  22. Mike said,

    Wrote on August 21, 2007 @ 8:05 pm

    Hi, I followed you instructions and I seem to have the same problem as Patrick. “Statusmap.cgi” is not avaialble.

    I have installed Nagios before on a different Linux platform and it worked after I applied the necessary Libraries, and ran “make install-cgis”.

    But this does not seem to work with your instruction method. I am running Ubuntu 7.04, and Nagios 3.01b.

  23. Bas said,

    Wrote on August 22, 2007 @ 8:48 am

    Your manual is briljant.

    10-15 minutes and running.

    Only there is one thing: “/nagios/cgi-bin/statusmap.cgi was not found on this server”.

    Do you have an answer to that?

    Thanks for the good work.

    BTW. I’m running Nagios 2.9 on UBUNTU 7.04 LAMP server.

  24. Chris Hu said,

    Wrote on August 28, 2007 @ 12:27 pm

    Hi - I followed your instructions but cannot login though the web. I just get an unable to connect message. Any ideas?

  25. Chris Hu said,

    Wrote on August 28, 2007 @ 1:20 pm

    I tried reinstalling again and i get a not found error

    Apache/2.0.55 (ubuntu) Server at localhost Port 80
    404 Not Found

  26. eliyac said,

    Wrote on September 28, 2007 @ 5:18 am

    Good morning!
    Great Tut…
    I have a problem
    I was trying to unistall my previous nagios, and I deleted my /usr/local/share/nagios file.
    Please can you email me your /usr/local/share/nagios file?

    I’ve been trying to install nagios since 2 days…:(

  27. Mike said,

    Wrote on October 2, 2007 @ 10:40 am

    Great how-to. I just finished installing Nagios 3.0b4 with it and it worked great! Thanks for taking the time to post this.

  28. David said,

    Wrote on October 12, 2007 @ 7:31 am

    For the ppl with statusmap issues (I’m using nagios 2.9). I found that the file smbackground.gd2 is missing. This file is the default background listed in cgi.cfg.

    Not sure why this file is missing from the distribution, but I believe this is what is causing the problem. Anyone know where I/we can get a copy of this file (sure we could use any background, but I like the default one :) )

    Cheers
    D

  29. David said,

    Wrote on October 12, 2007 @ 8:40 am

    Hmmm, redownloaded the same files, recompiled and now all my missing files are in place and everything is working.

  30. Oxana said,

    Wrote on October 16, 2007 @ 8:24 pm

    You are probably missing some libraries.
    See the link: http://www.nagios.org/faqs/viewfaq.php?faq_id=55

  31. Adriano said,

    Wrote on November 1, 2007 @ 8:55 am

    I’ve installed Nagios 2.8 and 2.10 following this guide and It’s working. \o/

    thx!

  32. Gregg said,

    Wrote on December 27, 2007 @ 5:56 am

    Excellent article. Thanks for the great work

  33. anuj singh said,

    Wrote on January 21, 2008 @ 2:33 am

    hi
    need your help

    i am getting following error

    ==============================================
    Access forbidden!

    You don’t have permission to access the requested object. It is either read-protected or not readable by the server.

    If you think this is a server error, please contact the webmaster.
    Error 403
    apt-amd-02
    Mon Jan 21 10:40:28 2008
    Apache/2.2.4 (Linux/SUSE)
    =========================================

    br
    anuj

  34. trial said,

    Wrote on February 4, 2008 @ 10:27 pm

    plz solve my problem..

    why nagios can’t open..this error appear!!

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.
    Apache/2.2.3 (Debian) Server at localhost Port 80

  35. Ari said,

    Wrote on March 27, 2008 @ 12:51 am

    Great article!

  36. Eddie said,

    Wrote on May 17, 2008 @ 10:04 pm

    Installed on Ubuntu Server 8.04, nagios 3.0.1 and plugins 1.4.11. Didn’t need to apt-get libgd2-dev, this must already be installed. Everything else was cut and paste. Thank you for a great guide.

  37. Shounak said,

    Wrote on May 21, 2008 @ 4:34 pm

    Thats a pretty neat tutorial you have there.
    Helps a lot.

    Thanks for all the good work. Keep it up.

  38. casino fantasy said,

    Wrote on July 19, 2008 @ 8:19 pm

    casino fantasy…

    Lome flask admirably Earp Johannes …

  39. worsro said,

    Wrote on August 2, 2008 @ 2:36 am

    You are great, You have made everything simple for me.
    Good Keep it up.

Comment RSS · TrackBack URI

Leave a Comment

Name: (Required)

E-mail: (Required)

Website:

Comment: