Building a Linux Monitoring Infrastructure I

Abayomi AYOOLAAbayomi AYOOLA
3 min read

Based on Nagios 3.0

This post describes the installation and configuration of a system monitoring infrastructure on Nagios, an open-source network monitoring application. This is the first in two series. Enjoy!

Nagios is an open-source infrastructure system and enterprise network monitoring application. It monitors hosts and services, alerting users when things go wrong and again when they get better. It was originally created under the name Netsaint, was written and is currently maintained by Ethan Galstad, along with a group of developers actively maintaining both official and unofficial plugins.

It was originally designed to run under Linux, but also runs well on other Unix variants and nowadays on Windows Operating Systems. It is free software licensed under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

FUNCTIONS
Some of the functions performed by Nagios include

Monitoring of network services (SMTP, POP3, HTTP, SSH)
Monitoring of host resources (processor load, disk usage, system logs) on a majority of Network Operating Systems, including Microsoft Windows with the NRPE_NT plugins.
Remote monitoring is supported through SSH or SSL-encrypted tunnels.
Simple plugin design that allows users to easily develop their own service checks depending on needs, by using the tools of choice (Bash, C++, Perl, Ruby, Python, PHP, C#, etc.)
Contact notifications when service or host problems occur and get resolved (via e-mail, pager, SMS, or any user-defined method through the plugin system)
Automatic log file rotation
Support for implementing redundant monitoring hosts
Optional web interface for viewing current network status, notifications, problem history, log files, etc

INSTALLATION

This particular deployment was carried out on Ubuntu Server 8.04. By default, Nagios would be installed underneath /usr/local/nagios and would be configured to monitor a few aspects of our local system (CPU load, disk usage, etc.). The Nagios web interface would be accessible at http://localhost/nagios/

Package Requirements
For the proper functioning of our installation, the following software packages are required:

Apache 2
GCC compiler and development libraries
GD development libraries

And in order to install them, just issue the following commands
aayoola@Nagios:~$ sudo apt-get install apache2
aayoola@Nagios:~$ sudo apt-get install build-essential
aayoola@Nagios:~$ sudo apt-get install libgd2-xpm-dev

For starters, I would like to explain the above. aayoola is the username on the server, which you would have given during or after the OS installation.

1. Create Account Information
Become the root user.
aayoola@Nagios:~$ sudo -s

Create a new nagios user account and give it a password.
root@Nagios:~#/usr/sbin/useradd -m nagios passwd nagios

On Ubuntu server edition (6.01 and possibly newer versions), you will need to also add a nagios group. You should be able to skip this step on desktop editions of Ubuntu.
root@Nagios:~#/usr/sbin/groupadd nagios
root@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.
root@Nagios:~# /usr/sbin/groupadd nagcmd
root@Nagios:~# /usr/sbin/usermod -a -G nagcmd nagios
root@Nagios:~#/usr/sbin/usermod -a -G nagcmd www-data

2. Download Nagios and the Plugins
Create a directory for storing the downloads.
root@Nagios:~#mkdir downloads

Enter the created folder
root@Nagios:~#cd downloads

Download Nagios as follow
root@Nagios:~/Downloads#wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.5.tar.gz

root@Nagios:~/Downloads# wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz

Be sure to confirm the links are still valid.

3. Compile and Install Nagios
Extract the Nagios source code tarball
root@Nagios:~/Downloads# tar xzf nagios-3.0.5.tar.gz cd nagios-3.0.5

Enter Nagios folder
root@Nagios:~/Downloads# cd nagios-3.0.5

Run the Nagios configure script, parsing the name of the group you created earlier like this:
root@Nagios:~/Downloads/nagios-3.0.5# ./configure —with-command-group=nagcmd

Compile the Nagios source code.
root@Nagios:~/Downloads/nagios-3.0.5# make all

0
Subscribe to my newsletter

Read articles from Abayomi AYOOLA directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Abayomi AYOOLA
Abayomi AYOOLA