Nagios

Nagios

From Consultancy.EdVoncken.NET

Jump to: navigation, search

Contents

About Nagios

Nagios is an excellent tool for monitoring and alerting. It is an extensible platform, with several add-ons and plugins available.

The main websites for Nagios related information are:

In 2009, Nagios was forked into Icinga. Development progresses at a faster pace compared to Nagios, but as of yet no standard RPM packages are available from the default or EPEL repositories. Check out the Icinga Documentation for more information.

Add-ons

Nagios functionality can be extended by installing add-ons. Graphing add-ons are very popular because Nagios does not keep a graphical history of performance metrics.

PNP4Nagios
Adds graphs to Nagios
NagiosGrapher
Adds graphs to Nagios
NagVis
Nagios Visualisation
NagTrap
SNMP Trap integration

Plugins

Nagios uses plugins for performing the actual monitoring. The standard set of plugins should suffice for most standard monitoring needs, and custom plugins can be installed for special monitoring requirements. You can also write your own plugins, for example as a simple shell script.

Writing Nagios plugins

Plugin repositories

There are some excellent repositories for Nagios plugins:

Various Plugins

Over time, I have written a couple of simple plugins to help me monitor various parameters.

Other interesting plugins out there:

Overview

A complete Nagios installation consists of multiple parts:

  • Nagios Server (with optional add-ons)
  • Nagios Clients (usually NRPE or SNMP)

In Unix/Linux environments, we usually deploy Nagios on the server plus NRPE on each client.

Installation

Nagios Server Installation

Installing a Nagios server on Red Hat Enterprise Linux or CentOS is quite simple. Nagios RPMs are available from the EPEL repository.

 yum -y install httpd
 yum -y install php
 yum -y install nagios
 yum -y install nagios-plugins-nrpe
 yum -y install pnp4nagios
 mkdir -p /etc/nagios/conf.d/template
 mkdir -p /etc/nagios/conf.d/general
 mkdir -p /etc/nagios/conf.d/host
 mkdir -p /etc/nagios/conf.d/service

You will also need plugins. To avoid unnecessary dependencies being installed, I no longer install the "nagios-plugins-all" package but selectively install each plugin.

 for plug in disk load ping procs users; do yum -y install nagios-plugins-${plug}; done

Verify your Nagios configuration:

 nagios -v /etc/nagios/nagios.cfg

Once you are happy with your configuration, enable Nagios:

 chkconfig nagios on
 service nagios start

Server Add-on: pnp4nagios

After you enable performance data processing in Nagios, relevant data will be kept in /var/lib/pnp4nagios, in the form of RRD files (Round Robin Database). If you want to erase all graph history, just delete everything under that directory.

Nagios Client Installation

We mostly use Nagios Remote Plugin Executer (NRPE) to monitor services on remote hosts.

 yum -y install nrpe
 for plug in disk load ping procs users; do yum -y install nagios-plugins-${plug}; done

Edit your /etc/nagios/nrpe.conf and open the firewall for port 5666/TCP from the Nagios server. Then, enable NRPE:

 chkconfig nrpe on
 service nrpe start

Configuration

Nagios Server Configuration

Nagios is configured through a collection of text-files. This is both a weak and a strong point; some people prefer "point-and-click" configuration, but that quickly becomes impractical when monitoring hundreds of different hosts and services. Text-files can be generated from your CMDB, or generated from templates.

Configuration files can be stored in a subdirectory structure to suit your requirements. I mostly use the following:

/etc/nagios/conf.d/general
Contacts and Time-periods
/etc/nagios/conf.d/template
Host- and Service templates
/etc/nagios/conf.d/host
Host definitions plus Hostgroup definitions
/etc/nagios/conf.d/service
Service definitions plus Servicegroup definitions