How to Install Nagios on Ubuntu Server?

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 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 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:

wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz

and

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

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:

cd nagios-3.0.6

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:

make install

make install-init

make install-config

make install-commandmode

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:

make install-webconf

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

/etc/init.d/apache2 reload

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:

cd nagios-plugins-1.4.11

Compile the plugins with the command:

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

Now install the plugins with the following commands:

make

make install

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:

http://ADDRESS_OF_NAGIOS_SERVER/nagios

Source: http://www.ghacks.net/2009/06/08/how-to-install-nagios-on-ubuntu-server/

0 comments: