Nagios Installation and Configuration: Part Two

NagiosIn the previous article, we introduced Nagios and began covering installation. In this article, we will continue our look at Nagios, covering configuration and installation of plugins.

Nagios Configuration

Now that Nagios has been installed, it’s time to configure it. Sample configuration files have been installed in the /usr/local/nagios/etc directory. For the most part, the settings in the sample files should work fine for getting started with Nagios. You should, however change the e-mail address associated with the nagiosadmin contact definition to the address you’d like to use for receiving alerts. To do so, you change the email field in /usr/local/nagios/etc/objects/contacts.cfg with your favorite editor.

Next, install the Nagios web config file in the Apache conf.d directory:

make install-webconf

Create a nagionsadmin account for logging into the Nagios web interface. Remember the password you assign to this account.

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

Now restart Apache to make the new settings take effect.

/etc/init.d/apache2 reload


Next, extract the Nagios plugins source code tarball:

tar xzf nagios-plugins-2.0.3.tar.gz

cd nagios-plugins-2.0.3

Compile and install the plugins:

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

make

make install

Now configure nagios to automatically start when the system boots:

ln -s /etc/init.d/nagios /etc/rc5.d/599nagios

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

You should now be able to access the Nagios web interface at the URL below. You’ll be promoted 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.

If you want to receive e-mail notifications for Nagios alerts, you need to install the mailx (Postfix) package:

sudo apt-get install mailx

sudo apt-get install postfix

You’ll have to edit the Nagios e-mail notification commands found in /usr/local/nagios/etc/objects/commands.cfg and change and /bin/mail references to /usr/bin/mail. Once you do that, you’ll need to restart Nagios to make the configuration changes live:

sudo /etc/init.d/nagios restart

In the next article, we’ll access Nagios via the web interface and configure it to work with pfSense.


External Links:

The official Nagios site

Nagios on Wikipedia

Nagios Installation and Configuration: Part One

NagiosNagios is an open source computer system monitoring, network monitoring and infrastructure monitoring software application. It enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes, and offers monitoring and alerting services. It alerts the users when things go wrong, and alerts them a second time when the problem has been resolved.

Nagios was originally designed to run under Linux, but it also runs well on other Unix variants. It is licensed under the terms of the GNU GPL version 2. It was originally created under the name NetSaint, and was written and maintained by Ethan Galstad along with a group of developers who are actively maintaining both the official (and unofficial) plugins. The name of NetSaint was changed in response to a legal challenge by owners of a similar trademark; Nagios is a recursive acronym which stands for “Nagios Ain’t Gonna Insist On Sainthood”.

Nagios includes the following capabilities, among others:

  • Monitoring of network services
  • Monitoring of host resources (processor load, disk usage, system logs) on a majority of network operating systems (including Microsoft Windows)
  • Monitoring of anything else like probes which have the ability to send collected data via a network to specifically written plugins
  • Monitoring via remotely run scripts via Nagios Remote Plugin Executor
  • Remote monitoring supported through SSH or SSL encrypted tunnels


Nagios Installation

The process of installing Nagios under Linux is fairly straightforward. First, you need to install some prerequisites, which you can get from the repositories. First, install Apache 2 and the Apache PHP libraries:

sudo apt-get install apache2
sudo apt-get install libapache2-mod-php5

Next, install the GCC compiler and development libraries:

sudo apt-get install build-essential

Finally, you need to install the GD 2 development libraries. With some distributions, you install it like this:

sudo apt-get install libdg2-dev

But with some newer distros (including Ubuntu 7.10 and above), the name of the gd2 library has changed:

sudo apt-get install libgd2-xpm-dev

Next, you need to set up the Nagios account. Start by becoming the root user:

sudo -s

Now create a new user and give it a password:

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

On some distros, you may need to add a group, but on newer server versions of Ubuntu, you can skip this step:

/usr/sbin/groupadd nagios
/usr/sbin/usermod -G nagios nagios

In either case, you will need to create a new nagcmd group for allowing external commands to be submitted through the web interface, and to add 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

Now you need to download the nagios souce code tarball from the download section of the official Nagios web site. You probably also want to download the plugins tarball as well. Unpack the tarball:

tar xzf nagios-4.0.8.tar.gz
cd nagios-4.0.8

Then run the configure script, passing the name of the group you created earlier:

./configure –with-command-group=nagcmd

Compile the source code:

make all

Next, install the 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

This takes care of Nagios installation. In the next article, we will cover installation of the plugins and configuration.


External Links:

The official Nagios site

Nagios on Wikipedia

© 2013 David Zientara. All rights reserved. Privacy Policy