Friday, May 3, 2013

Installing Nagios 3.5 on Ubuntu 12.04 with Plugins 1.4.11

Nagios is a powerful monitoring system that enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes.



First launched in 1999, Nagios has grown to include thousands of projects developed by the worldwide Nagios community. Nagios is officially sponsored by Nagios Enterprises, which supports the community in a number of different ways through sales of its commercial products and services.

Nagios monitors your entire IT infrastructure to ensure systems, applications, services, and business processes are functioning properly. In the event of a failure, Nagios can alert technical staff of the problem, allowing them to begin remediation processes before outages affect business processes, end-users, or customers. With Nagios you'll never be left having to explain why a unseen infrastructure outage hurt your organization's bottom line.

This is how we installed Nagios Core 3.5 in Ubuntu 12.04 with Plugins V. 1.4.11


Step 1 : Install the necessary packages and libraries


You have to install the following packages on your Ubuntu installation before continuing.

    Apache 2
    PHP
    GCC compiler and development libraries
    GD development libraries

You can use apt-get to install these packages by running the following commands:

sudo apt-get install apache2

sudo apt-get install libapache2-mod-php5

sudo apt-get install build-essential

sudo apt-get install libgd2-xpm-dev



Step 2 : Create Account Information

Become the root user.

sudo -s

Create a new nagios user account and give it a password.

/usr/sbin/useradd -m -s /bin/bash nagios

passwd nagios

________________________________________________________________

On older Ubuntu server editions (6.01 and earlier), you will need to also add a nagios group (it's not created by default). You need not to do this step on new editions of Ubuntu.

/usr/sbin/groupadd nagios

/usr/sbin/usermod -G nagios nagios 


________________________________________________________________

Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.

/usr/sbin/groupadd nagcmd

/usr/sbin/usermod -a -G nagcmd nagios

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


Step 3 : Download Nagios and the Plugins

Create a directory for storing the downloads.

mkdir ~/downloads

cd ~/downloads


Download the source code tarballs of both Nagios and the Nagios plugins (visit http://www.nagios.org/download/ for links to the latest versions). These directions were tested with Nagios 3.5.0 and Nagios Plugins 1.4.11.

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz

wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz


________________________________________________________
If you don't have wget installed you can install it by using the command below

sudo apt-get install wget
________________________________________________________

Step 4 : Compile and Install Nagios

Extract the Nagios source code tarball.

cd ~/downloads

tar xzf nagios-3.5.0.tar.gz

cd nagios


Run the Nagios configure script, passing the name of the group you created earlier like so:

./configure --with-command-group=nagcmd

Compile the Nagios source code.
 

make all

Install binaries, init script, sample config files and set permissions on the external command directory.

make install

make install-init

make install-config

make install-commandmode


Don't start Nagios yet - there's still more that needs to be done...

Step 5 : Configure the Web Interface

Install the Nagios web config file in the Apache conf.d directory.

make install-webconf

Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later.

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

Restart Apache to make the new settings take effect.

/etc/init.d/apache2 reload

Step 6 : Compile and Install the Nagios Plugins

Extract the Nagios plugins source code tarball.

cd ~/downloads

tar xzf nagios-plugins-1.4.11.tar.gz

cd nagios-plugins-1.4.11


Compile and install the plugins.

./configure --with-nagios-user=nagios --with-nagios-group=nagios

make

make install


Step 7 : Start Nagios

Configure Nagios to automatically start when the system boots.


ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Verify the sample Nagios configuration files.

 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there are no errors, start Nagios.

/etc/init.d/nagios start

Step 8 : Login to the Web Interface

You should now be able to access the Nagios web interface at the URL below. You'll be prompted for the username (nagiosadmin) and password you specified earlier.

http://localhost/nagios/

Click on the "Service Detail" navbar link to see details of what's being monitored on your local machine. It will take a few minutes for Nagios to check all the services associated with your machine, as the checks are spread out over time.



 

14 comments:

  1. Hi, I got an error when installing the plugins. This may be because I installed a later version of the plugins (1.4.16) but the answer is:

    Before configure the source install libssl-dev:

    apt-get install libssl-dev

    After that:

    ./configure --with-nagios-user=nagios --with-nagios-group=nagios
    make
    make install

    Answer found at:
    http://ubuntuforums.org/showthread.php?t=2028488

    Kind regards,

    Peter

    ReplyDelete
  2. Thank you for the walk thru though. It was excellent. Made my installation go very quickly.

    For reference the error I received above was on the make:

    make[2]: *** [check_http.o] Error 1
    make[2]: Leaving directory `/home/nicadmin/nagios-plugins-1.4.16/plugins'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/nicadmin/nagios-plugins-1.4.16'
    make: *** [all] Error 2
    nicadmin@nicadmin-ubuntu:~/nagios-plugins-1.4.16$

    ReplyDelete
    Replies
    1. Pleased to hear that you got use of the post :D and thanks for the feedback , The cause for the problem should be the version of the Plugins that you try to install,but then again you have found the answer ! Good Luck with Nagios..

      Delete
  3. hey iam using nagios 3.0.2 and am upgrade to nagios 3.0.5 but it is not work how resolve proplem

    ReplyDelete
  4. Thanks for posting this, most of it makes sense and works however the problem that I have experienced is that I remain at Nagios 3.2.3 on web page login! I initially installed slightly differently using the apt-get and this installed 3.2.3, then I followed update process for 3.5.0 but even after retsarting system is shows 3.2.3 on web login page. Help please?

    ReplyDelete
  5. We've been busy for a while and just saw your questions.Currently trying to get some answers

    ReplyDelete
  6. Hi,

    Thanks for your guide man really appreciate it!

    I just stumbled on to something,

    in the

    Step 5 : Configure the Web Interface

    Install the Nagios web config file in the Apache conf.d directory.

    make install-webconf

    there's an error of

    make: *** No rule to make target `install-webconf'. Stop.

    Did I do something wrong???

    Thanks in advance!

    ReplyDelete
  7. ./configure --with-nagios-user=nagios --with-nagios-group=nagios using this command i have the error like this,
    make[2]: *** [check_pgsql.o] Error 1
    make[2]: Leaving directory `/home/harsha/downloads/nagios-plugins-1.4.11/plugins'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/harsha/downloads/nagios-plugins-1.4.11'
    make: *** [all] Error 2
    What will i do?

    ReplyDelete
    Replies
    1. Just have a look to the first comment of this blog : Peter SomersMay 17, 2013 at 9:43 AM.
      You will got the solution

      Delete
  8. Nice howto. I was looking for some since a little time and yours is perfect. Direct and only what we need.
    However, I would suggest you to add an 'apt-get install snmp' at the begining of your process so that nagios plugin will install the check_snmp which is very usefull nowdays :)

    ReplyDelete
  9. Great Work ! It cuts the search time by almost 90%

    ReplyDelete
  10. Hi ,
    The nagios Plugins are no longer to be found at sourceforge.net
    they can be found at

    https://www.nagios-plugins.org/download/

    ReplyDelete
  11. Hi, i am running Ubunut 12.04 desktop and after successfull installation of nagios i have this error when trying to start nagios:

    ./nagios: 20: .: Can't open /etc/rc.d/init.d/functions

    Any useful tips? I found some, but I am new to linux and I'm kinda lost.

    Thanks in advance

    ReplyDelete
  12. Hi There,


    Three cheers to you ! Hooray!!! I feel like I hit the jackpot on I Feel Success InternZ!

    I have earlier ask for help but I still have problem with installing Mageia,
    Why it is so difficult.? I have a laptop HP where I want to install some Linux to play with but I cannot find an installation that I can copy to a USB or a CD så I can install in this Laptop.
    This Laptop has not internet connection yet and have a windows XP OS until now but I want to convert it to Linux.
    It was cool to see your article pop up in my google search for the process yesterday. Great Guide.
    Keep up the good work!


    Shukran,
    Abhiram

    ReplyDelete