From Segfault
Jump to navigation Jump to search


git clone git:// pnp4nagios-git

We'd like to install in /opt but with the performance data stored undeneath our already existing Nagios installation:

./configure --prefix=/opt/pnp4nagios --with-nagios-user=nagios --with-nagios-group=nagios \
            --localstatedir=/var/lib/nagios3/pnp4nagios --with-httpd-conf=/opt/pnp4nagios/etc/apache
make all

sudo make install install-config install-html install-plugins install-webconf


We also need to decide how performance data is collected. PNP4Nagios offers serveral modes how to do this. In short:

  • Synchronous Mode - gets called for every Nagios check run.
  • Bulk Mode - Performance data is written to a temporary file, which will be processed by later on.
  • Bulk Mode with NPCD - As with Bulk Mode, performance data is written to a temporary file. The temporary file is moved to a spool directory, which will then be processed by NPCD ("Nagios Performance C Daemon").
  • Bulk Mode with npcdmod - Same as Bulk Mode, but implemented with npcdmod.o, a NEB (Nagios Event Broker) module.
  • Gearman Mode - PNP4Nagios driven as a Gearman worker. A mod_gearman environment is required.

Bulk mode

For our installation Bulk mode will be sufficient. Modifications to nagios.cfg are needed to make this work:

process_performance_data   = 1

# host_perfdata_command    = process-host-perfdata           # Don't need to be set for bulk mode
# service_perfdata_command = process-service-perfdata        # Don't need to be set for bulk mode

host_perfdata_file         = /var/lib/nagios3/pnp4nagios/perfdata/host-perfdata
service_perfdata_file      = /var/lib/nagios3/pnp4nagios/perfdata/service-perfdata


host_perfdata_file_mode        = a                          # append, write, pipe
service_perfdata_file_mode     = a

host_perfdata_file_processing_interval    = 15
service_perfdata_file_processing_interval = 15

host_perfdata_file_processing_command     = process-host-perfdata-file
service_perfdata_file_processing_command  = process-service-perfdata-file

These processing commands need to be registered with Nagios, in commands.cfg:

# process-service-perfdata-file
define command {
      command_name    process-service-perfdata-file
      command_line    /opt/pnp4nagios/libexec/ \
# process-host-perfdata-file 
define command {
      command_name    process-host-perfdata-file
      command_line    /opt/pnp4nagios/libexec/ \

With all that in place, Nagios can be restarted to activate performance data collection. We can verify our configuration with:

cd ~/pnp4nagios-git
sudo scripts/ -c /etc/nagios3/nagios.cfg -p /opt/pnp4nagios/etc -m bulk

Nagios Integration

For PNP4Nagios to show up in the Nagios web frontend, we will create templates for both service and host performance graphs:

$ cat generic-pnp.cfg
define host {
       name            pnp-host
       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            pnp-service
       action_url      /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
       action_url      /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
       register        0

Now, in our generic-host.cfg template definition, we can add:

define host {
       use               pnp-host

Note: in the action_url above we have already added the popup feature, so that a small preview of a graph is being overlayed during mouse-over. For this to work, we need to add some Javascript code to our Nagios installation. For a Debian installation, this might look like this:

cd ~/pnp4nagios-git
sudo cp contrib/ssi/status-header.ssi /usr/share/nagios3/htdocs/ssi/
sudo chmod 0644 /usr/share/nagios3/htdocs/ssi/status-header.ssi

With Thruk installed, these SSI files are already included, but have to be activated:

cd /etc/thruk/ssi/
ln -s extinfo-header.ssi{.example,}
ln -s status-header.ssi{.example,}

Restart Thruk and each check using the service-pnp or host-pnp template should display a small popup now during mouseover.


For PNP4Nagios to work, some PHP settings needed to be modified:

  • Add the following paths to open_basedir
  • Remove the following from disable_functions
; proc_open     - pnp4nagios: Undefined variable: pipes, 
                  application/models/rrdtool.php [36]
; proc_close    - pnp4nagios: proc_close() has been disabled for security reasons, 
                  application/models/rrdtool.php [52]