Icinga Graphs with PNP under Ubuntu 12.04 Precise

From Thomas-Krenn-Wiki
Jump to navigation Jump to search
Please note that this article / this category refers either on older software / hardware components or is no longer maintained for other reasons.
This page is no longer updated and is purely for reference purposes still here in the archive available.

The following article will explain how to modify an existing Icinga 1.6.1 under Ubuntu 12.04 with PNP4Nagios for the presentation of performance data as graphs. Any software required will be installed from the package sources. Self-compiling of software will not be required.

Installing PNP

The "pnp4nagios" package will be installed from the package sources.

:~$ sudo apt-get install pnp4nagios
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  apache2-mpm-prefork fontconfig fontconfig-config javascript-common libapache2-mod-php5 libcairo2
  libdatrie1 libdbi1 libfontconfig1 libfpdf-tpl-php libfpdi-php libgd2-xpm libjs-jquery-ui
  libkohana2-php libpango1.0-0 libpixman-1-0 librrd4 librrds-perl libt1-5 libthai-data libthai0
  libxcb-render0 libxcb-shm0 libxft2 libxpm4 libxrender1 php-fpdf php5-cli php5-common php5-gd
  pnp4nagios-bin pnp4nagios-web rrdtool ttf-dejavu ttf-dejavu-core ttf-dejavu-extra wwwconfig-common
Suggested packages:
  php-pear libgd-tools libjs-jquery-ui-docs libkohana2-modules-php ttf-baekmuk ttf-arphic-gbsn00lp
  ttf-arphic-bsmi00lp ttf-arphic-gkai00mp ttf-arphic-bkai00mp ttf2pt1 php5-suhosin rrdcached
  libgearman-client-perl libcrypt-rijndael-perl mysql-client postgresql-client
The following packages will be REMOVED:
  apache2-mpm-worker libgd2-noxpm
The following NEW packages will be installed:
  apache2-mpm-prefork fontconfig fontconfig-config javascript-common libapache2-mod-php5 libcairo2
  libdatrie1 libdbi1 libfontconfig1 libfpdf-tpl-php libfpdi-php libgd2-xpm libjs-jquery-ui
  libkohana2-php libpango1.0-0 libpixman-1-0 librrd4 librrds-perl libt1-5 libthai-data libthai0
  libxcb-render0 libxcb-shm0 libxft2 libxpm4 libxrender1 php-fpdf php5-cli php5-common php5-gd
  pnp4nagios pnp4nagios-bin pnp4nagios-web rrdtool ttf-dejavu ttf-dejavu-core ttf-dejavu-extra
  wwwconfig-common
0 upgraded, 38 newly installed, 2 to remove and 3 not upgraded.
Need to get 16.3 MB of archives.
After this operation, 44.6 MB of additional disk space will be used.
Do you want to continue [Y/n]?
[...]
Get:33 http://de.archive.ubuntu.com/ubuntu/ precise/universe pnp4nagios-bin amd64 0.6.13-1 [78.2 kB]
Get:34 http://de.archive.ubuntu.com/ubuntu/ precise/main rrdtool amd64 1.4.7-1 [369 kB]
Get:35 http://de.archive.ubuntu.com/ubuntu/ precise/universe pnp4nagios-web all 0.6.13-1 [1,099 kB]
Get:36 http://de.archive.ubuntu.com/ubuntu/ precise/universe pnp4nagios all 0.6.13-1 [6,118 B]
[...]

Configuring PNP

Configuring PNP if installed from the Ubuntu repository differs primarily in the paths where the config files are located.

:~# ls /etc/pnp4nagios/
apache.conf     config.php  pages                 rra.cfg
background.pdf  nagios.cfg  pnp4nagios_release    templates
check_commands  npcd.cfg    process_perfdata.cfg  templates.special

After installing Icinga from the repository, the Icinga service will be running as the "nagios" user.

:~# ps -u nagios
  PID TTY          TIME CMD
 3890 ?        00:00:00 icinga
 3967 ?        00:00:00 npcd

Thus, changing the user and group, which the PNP service uses for running, is no longer necessary (in contrast if self-compiled)[1].

However, it must be ensured that the base Uniform Resource Locator (URL) in "config.php" points to Icinga.

:~# vi /etc/pnp4nagios/config.php
$conf['nagios_base'] = "/icinga/cgi-bin";

No further configuration steps will not be necessary for installing PNP from the repository. However, the collaboration with Icinga must still be configured. The logging mechanism can be activated as needed.

:/etc/pnp4nagios# vi npcd.cfg
log_type = file
log_file = /var/log/pnp4nagios/npcd.log
log_level = 2
:/etc/pnp4nagios# vi process_perfdata.cfg
#
# name of the log file
#
LOG_FILE = /var/log/pnp4nagios/perfdata.log

#
# Loglevel 0=silent 1=normal 2=debug
#
LOG_LEVEL = 2

Finally, one decisive must still be made. The path for the htaccess file must be adjusted in the "apache.conf" file in the PNP configuration directory.

:~# vi /etc/pnp4nagios/apache.conf
[...]
AuthUserFile /etc/icinga/htpasswd.users
[...]

Without this change, requests for the "$IP-ADRESSE/pnp4nagios" page will fail.

Integrating PNP into Icinga

Prior to configuration, a PNP processing mode must be choosen.[2] The "Bulk Mode with NPCD and npcdmod" will be set in the following example.[3]

:~# cd /etc/icinga/
:/etc/icinga# vi icinga.cfg
process_performance_data=1
broker_module=/usr/lib/pnp4nagios/npcdmod.o config_file=/etc/pnp4nagios/npcd.cfg

The "process_performance_data" option will be set to "1". The line with the "broker_module" entry will be created.

Testing PNP Functionality

PNP4Nagios Environment Tests

To activate the test web page, the "install.ignore" file must be temporarily renamed.

:/usr/share/pnp4nagios/html# mv install.ignore install.ignore.orig

An installation page will then appear when the PNP interfaces is required from "$IP-ADRESSE/pnp4nagios" (cf. the figure on the right). If the file is renamed to "install.ignore", this page will no longer appear.

Configuring Icinga

The so-called "action_url templates" will first be created.[4]

:/etc/icinga/objects# vi pnptemplate.cfg
define host {
        name       pnp-hst
        register   0
        action_url /pnp4nagios/graph?host=$HOSTNAME$' class='tips' rel='/pnp4nagios/popup?host=$HOSTNAME$&srv=_HOST_
}

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

In addition, the PNP templates for the host and service templates will be added.

:/etc/icinga/objects# vi generic-host_icinga.cfg
define host{
        name                            generic-host    ; The name of this host template
        use                             pnp-hst
  ...
:/etc/icinga/objects# vi generic-service_icinga.cfg
define service{
        name                            generic-service ; The 'name' of this service template
        use                             pnp-svc
  ...

Finally, the "status-header.ssi" file will also be copied into the Icinga SSI folder.

:~# cd /usr/share/icinga/htdocs/ssi
:/usr/share/icinga/htdocs/ssi# cp /usr/share/doc/pnp4nagios/examples/ssi/status-header.ssi .

Once Apache has been restarted, the performance graphs will become visible from the Icinga Classic Interface.

Icinga-pnp-integration.png

References

  1. Setting up PNP with Icinga (wiki.icinga.org)
  2. pnp4nagios modes (docs.pnp4nagios.org)
  3. Bulk mode with npcdmod (dos.pnp4nagios.org)
  4. pnp4nagios in Classic UI (wiki.icinga.org)

Related articles

Icinga 1.6.1 Installation for Ubuntu 12.04 Precise
Installing VMware Tools under Debian
Simple Samba Shares in Debian