Introduction

I’ve covered a few basics of working with Icinga previously and now I’ve finally got round to installing pnp4nagios so I can work with historical performance data.  In this post I’ll detail installing pnp4nagios and integrating it with Icinga 1 and the Classic UI.  I performed these exact steps on Ubuntu 12.04 (in a VM) and Raspbian on a Raspberry Pi.

NOTE: The Raspberry Pi performance wasn’t fantastic while navigating graphs but it worked without error.  See Appendix A at the end of the article for a small tweak to help performance on the Pi.

Installation

Ensure you’ve already installed Icinga (Raspberry Pi / Deabian based instructions can be found on another post here) and then complete the package installation.

$ sudo apt-get update

$ sudo apt-get install pnp4nagios

Icinga Updates

Update an incorrect htpasswd reference (currently pointing to a nagios3 installation) to Icinga:

$ sudo nano /etc/pnp4nagios/apache.conf

Change : AuthUserFile /etc/nagios3/htpasswd.users
To : AuthUserFile /etc/icinga/htpasswd.users

Update the Icinga cgi-bin path for the web front end (~line 92 in this file)

$ sudo nano /etc/pnp4nagios/config.php

Change : $conf[‘nagios_base’] = “/cgi-bin/nagios3”;
To : $conf[‘nagios_base’] = “/cgi-bin/icinga”;

Configuration

The performance data processing mode selected is Bulk Mode with NPCD and npcdmod.  This is the recommended method in the pnp4nagios documentation.  It has the advantages of Bulk Mode with NPCD (in that it doesn’t pause Icinga checks while running and has the same performance) but has less configuration for us.

$ sudo nano /etc/icinga/icinga.cfg

NOTE: You can search in nano using Ctrl+W

Change : process_performance_data=0
To : process_performance_data=1

Add this line to the broker_module section (~line 264)
broker_module=/usr/lib/pnp4nagios/npcdmod.o config_file=/etc/pnp4nagios/npcd.cfg

pnp4nagios-rpi8

Enable the npcd service:

$ sudo nano /etc/default/npcd

Change : RUN=”no”
To : RUN=”yes”

Initial Test

Enable the pnp4nagios install page to be viewed by renaming the install.ignore file:

$ sudo mv /usr/share/pnp4nagios/html/install.ignore /usr/share/pnp4nagios/html/install.ignore.orig

Reload apache2 and restart icinga services:

$ sudo service apache2 reload

$ sudo service icinga restart

Browse to http://<your_ip_address>/pnp4nagios login as your Icinga user and you should see the following Environment Tests (all showing green)

 

When the test has complete, rename the install.ignore file back again:

$ sudo mv /usr/share/pnp4nagios/html/install.ignore.orig /usr/share/pnp4nagios/html/install.ignore

Integrate with Icinga Classic UI

First set up a new configuration file that will contain the action_url for the pop up graphs when hovering over the gear icon.  For example:

pnp4nagios-rpi3

There are a couple of ways of doing this (e.g. adding the directives straight into your generic host/service templates or your host/service definitions) but the method specified in the pnp4nagios documentation appears best for usability.  Create a new configuration file:

$ sudo nano /etc/icinga/objects/pnptemplates.cfg

Then populate it with the following definitions and directives:

define host {
	name       host-pnp
	action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
	register   0
}

define service {
	name       srv-pnp
	action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
	register   0
}

Finally set up your generic host and service templates to use the new templates above:

$ sudo nano /etc/icinga/objects/generic-host_icinga.cfg

Add the follow directive in the defintion:

	use			host-pnp

$ sudo nano /etc/icinga/objects/generic-service_icinga.cfg

Add the follow directive:

	use			srv-pnp

Finally, to display the popups in your browser copy the status-header.ssi file to the icinga ssi directory.

$ sudo cp /usr/share/doc/pnp4nagios/examples/ssi/status-header.ssi /usr/share/icinga/htdocs/ssi/status-header.ssi

Restart (or start) the relevant services:

$ sudo service npcd start

$ sudo service icinga restart

$ sudo service apache2 restart

Final Testing

Browse to http://<your_ip_address>/icinga, login as your Icinga user and browse to the localhost service detail.  You should see gear icons beside most of the checks:

pnp4nagios-rpi2

After 5-10 minutes (depending on you check frequency) the performance data should start to populate and you can hover over one of the gear icons to see a pop up graph (as shown in an earlier section).  If you click on the gear you’ll be taken to the dedicated page for the performance graphs as shown below.

pnp4nagios-rpi4

Here’s an example of a Windows disk space graph:

pnp4nagios-rpi5

There are a variety of settings in the /etc/pnp4nagios/config.php file.  One of the simpler ones is the JQuery UI Theme (~line 164).  There are four to choose, here’s the redmond one:

pnp4nagios-rpi6

You can also set a multitude of other options in this file (e.g. graph sizes, default graphs etc)

Summary

Hopefully this post has got you up and running with pnp4nagios and Icinga 1 (with Classic UI) fairly quickly.  Remember, the plugin you use must supply performance data for it to be graphed!

The complete pnp4nagios documentation can be found here.

Appendix A – Performance on the Raspberry Pi

If you’re adding pnp4nagios to your Raspberry Pi Icinga installation I found using rrdcached (mentioned in the pnp4nagios documentation when working with larger environments) decreased the average load slightly.  This was only on a small monitoring list (8 systems and 33 services).  You can read about rrdcached here (including a description of the daemon options).

Install the rrdcached package:

$ sudo apt-get install rrdcached

Configure a directory for the cache in case of failure before data is flushed to the RRD files.

$ sudo mkdir -p /var/cache/rrdcached

Configure the rrdcached daemon with the following options:

$ sudo nano /etc/default/rrdcached

Change to:
OPTS=”-w 1800 -z 1800 -j /var/cache/rrdcached -s nagios -m 0660 -l unix:/var/run/rrdcached.sock”

Configure pnp4nagios to use rrdcached:

$ sudo nano /etc/pnp4nagios/process_perfdata.cfg

Line 86, change to:
RRD_DAEMON_OPTS = unix:/var/run/rrdcached.sock

$ sudo nano /etc/pnp4nagios/config.php

Line 225, change to:
$conf[‘RRD_DAEMON_OPTS’] = ‘unix:/var/run/rrdcached.sock’;

Add the apache2 account (www-data) to the nagios group and restart the services:

$ sudo usermod -G nagios -a www-data

$ sudo service rrdcached restart

$ sudo service apache2 restart

Load graph without rrdcached:

pnp4nagios-rpi-load1

Load graph with rrdcached configured:

pnp4nagios-rpi-load2

Update 1 (04/08/2014) – Fixed the nagios_base path for Icinga in config/php – should be /cgi-bin/icinga.

Update 2 (05/08/2014) – Added an appendix for Raspberry Pi users and rrdcached performance tweak.


Install Icinga 1 Core on the Raspberry Pi

Some Icinga Core basics – Part One

Some Icinga Core basics – Part Two

Some Icinga Core basics – Part Three

Some Icinga Core basics – Part Four

Some Icinga Core basics – Part Five

 

Install pnp4nagios on Icinga 1 Classic UI
Tweet about this on TwitterShare on Google+0Share on Facebook0Email this to someone
Tagged on:                     

One thought on “Install pnp4nagios on Icinga 1 Classic UI

  • 11 April 2017 at 01:54
    Permalink

    Thank you so much, I needed to setup an Icinga replacement server with pnp4nagios on the fly and this article saved me big time.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *