Ready to Start Your Career?

Building a Linux Monitoring Infrastructure With Nagios 3.0

Abayomi Ayoola's profile image

By: Abayomi Ayoola

January 21, 2017

nagios-ubuntu-install

Estimated reading time: 3 minutes

This post describes the installation and configuration of a system's 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 a free software licensed under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

FUNCTIONSSome of the functions performed by Nagios include

Monitoring of network services (SMTP, POP3, HTTP, SSH)Monitoring of host resources (processesor load, disk usage, system logs) on a majority of Network Operating System, including Microsoft Windows with the NRPE_NT plugins.Remote monitoring 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 plugin system)Automatic log file rotationSupport for implementing redundant monitoring hostsOptional web-interface for viewing current network status, notifications, problem history, log files, etcFound on Sourceforge.net

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 RequirementsFor the proper functioning of our installation, the following software packages are required:

Apache 2GCC compiler and development librariesGD development libraries

And in order to install them, just issue the following commandsaayoola@Nagios:~$ sudo apt-get install apache2aayoola@Nagios:~$ sudo apt-get install build-essentialaayoola@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 InformationBecome 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 possible 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 nagiosroot@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 nagcmdroot@Nagios:~# /usr/sbin/usermod -a -G nagcmd nagiosroot@Nagios:~#/usr/sbin/usermod -a -G nagcmd www-data

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

Enter the created folderroot@Nagios:~#cd downloads

Download Nagios as followroot@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 NagiosExtract the Nagios source code tarballroot@Nagios:~/Downloads# tar xzf nagios-3.0.5.tar.gz cd nagios-3.0.5

Enter Nagios folderroot@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


Fedora installation instructions can be found here.

Alternate instructions for Ubuntu are also available here.

Schedule Demo