Install Nagios in 600 seconds…

Recently I installed Nagios from the Ubuntu 10.04 repositories and found that the repository version is a version behind the current behind. I decided to install Nagios from source code directly. It is a simple process, below is how it is installed. Note there are two parts to Nagios, the core application and the plugins.

Nagios Core:

We need to install dependancies before we install nagios.

# apt-add install build-essential php5-gd wget libgd2-xpm libgd2-xpm-dev

We now need to create the nagios user on the system, for the nagios software to run under.

# adduser –system –no-create-home –disabled-login –group nagios

# groupadd nagcmd

# usermod -G nagcmd nagios usermod -a -G nagcmd www-data

Now that we have create the nagios user for the system, we need to download the nagios software.

# cd /usr/src

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

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

Now we build the Nagios software

# tar -xzvf /opt/nagios-3.3.1.tar.gz cd /opt/nagios-3.2.3 ./configure –with-command-group=nagcmd

# cd nagios-3.3.1

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

We now compile the software and install it, upon the system.

# make all

# make install

# make install-init

# make install-config

# make install-commandmode

Configure the Nagios core.

# vi /usr/local/nagios/etc/objects/contacts.cfg

You need to edit the alias and email lines.

# cd /usr/src/nagios-3.3.1

We need to install the web based frontend software.

# make install-webconf

We need to create the login name of the user from the apache frontend. You wil also need to enter a password for the nagiosadmin user.

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

We need to reload the apache2 configuration.

# /etc/init.d/apache2 reload

Nagios Plugin:
We now need to build the plugins from source. Below are the steps below.

# cd /usr/src

# tar xzf nagios-plugins-1.4.15.tar.gz

# cd nagios-plugins-1.4.15.tar.gz

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

# make

# make install

Now we get Nagios running. We need to get the permissions corrected so the startup files work.

# chmod +x /etc/init.d/nagios

# /usr/sbin/update-rc.d -f nagios defaults

We need to check that our nagios configuration is good, or Nagios will not start. The configuration check will show us if there are any errors in the configuration file.

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

If no errors are shown, you are able to start Nagios now.

# /etc/init.d/nagios start

You will be able to access Nagios from a web browser. The address will be http://localhost/nagios or http://<ip address of the server>/nagios Remember when you created the Nagios admin user above, you need to remember

Mail Alerts

If you want Nagios to email you on alerts, when things go wrong. You need to install

#apt-get install mailutils sendmail

Select your mail server as a internet site. Note that you can modify the nagios /usr/local/nagios/etc/objects/commands.cfg file or easier process is to link /usr/bin/mail to /bin/mail. You do not need to restart nagios if you just done the soft link of the mail files.