Personal tools
You are here: Home Projects PNP4Nagios

PNP4Nagios Overview

by Herbert Straub last modified 2008-06-04 20:32

PNP for Nagios is a performance data visualization tool.

Coding Style

Coding style for the PNP source code. Read more

Version 0.4.8.x

The pnp4nagios-hs contains the following changes to the original 0.5.8 version:

  • process_perfdata.pl: adding normalize_values function
  • RRD Datatype definition per DS number
  • Removing AC_STRUCT_DIRENT_D_TYPE
  • fixing --datadir configure option
  • fixing make fullinstall with install-processperfdata install-html
  • fixing make-install and add to fullinstall
  • add check_hddtemp.php
  • add check_iftraffic.php
  • bug fix process _perfdata.pl use RRD's detection failed (this is fixed in pnp-0.4.9)
  • add NORMALIZE_VALUES parameter
  • add check_disk1.php working with NORMALIZE_VALUES
  • add helper_functions.php

The new templates generates this pictues. The harddisk temperature

PNP harddisk temperature

and network traffic

PNP check_iftraffic

and the disk usage

PNP disk_usage

Configuration Examples

Overview

The pathes in the following configuration examples are valid for the RPM Installation (pnp4nagios-hs). The configuration home of Pnp4nagios-hs is /etc/pnp4nagios. The user supplied template configuration directory is: /etc/pnp4nagios/templates/

DS Datatypes

Your Nagios Plugin (check_iftraffic) supplies for example four performance values and the corresponding Datatype for RRD should be: Counter, Counter, Gauge, Gauge. The you create the configuration file /etc/pnp4nagios/check_iftraffic.cfg with the following contents:

     DATATYPES=COUNTER:COUNTER:GAUGE:GAUGE 

You can check the datatype in the database with the command:

      rrdtool info /var/lib/pnp4nagios/perfdata/localhost/Interface_eth2_WAN.rrd

Normalize Values

This feature converts the performance data and store the basis values in the RRD. For example: the performance data of the disk plugins is 450Mbytes. If the normalization function is enabled, then pnp4nagios-hs converting 450 to 450*10^6 Bytes and store this value. Attention! You have to convert you existing RRD's, if you would use your historical data! There is no automatic convertion. This feature is enabled with the following configuration line in '/etc/pnp4nagios/process_perfdata.cfg':

      # NORMALIZE_VALUES
      # Converting to base unit before storing values in RRD.
      # For example kB in Bytes and ms in s
      #
      NORMALIZE_VALUES = 1

Source Code

The pnp-0.4.8-to-pnp4nagios-hs-0.4.8.1.patch containing all changes. The complete tar is also availeble pnp4nagios-hs-0.5.8.1 . If you have any question, feel free and contact me.

Pnp4Nagios RPM

I'm trying to be LSB conform with the RPM. These are key directories:

  • /etc/pnp4nagios the main configuration directory.
  • /etc/pnp4nagios/templates the user supplied templates are stored here.
  • /var/lib/pnp4nagios/perfdata containing the RRD's
  • /usr/lib64/pnp4nagios/process_perfdata.pl the Nagios service_perfdata_command

The actual version is available for CentOS5:

Patch overview for (0.)2.4

Changelog

  • Pnp 2.4 and ferformance data label with spaces
  • Pnp 2.4 and unit base, example 34kMB (means 34GB)
  • Pnp 2.4 and changes DS in RRD

Here is the full page pnp-2.4-hs.patch - details see below

Pnp 2.4 and Label with Spaces

The check_snmp_storage plugin creates a label with spaces 'C:\ ...'=... The parameter illegal_macro_output_chars in nagios.cfg have to modify:

        illegal_macro_output_chars=`~$&|"<>

If this parameter contains a single quote character, then this character will not writtendo the service_perfdata_command and not to pnp. The next logfile sequence shows the labels inthe turn loop. The leading single quote character and ending single quote character are not correctly parsed and stored:

        2006-11-01 10:23:15 [3765] found Performance Data for localhost / Fake check_snmp_st orage ( 'C:\ Label:  Serial Number bc22aa2e'=8015MB;16387;18435;0;20484 'D:\ Label: Serial Number XA22aa2e'=8015MB;16387;18435;0;20484 )
        2006-11-01 10:23:15 [3765] Searching Custom Template for check_snmp_storage
        2006-11-01 10:23:15 [3765] No Custom Template found for check_snmp_storage
        2006-11-01 10:23:15 [3765] Template is check_snmp_storage.php
        2006-11-01 10:23:15 [3765] RRD Data Type = GAUGE
        2006-11-01 10:23:15 [3765] Perfdata contains spaces ('C:\ Label:  Serial Number bc22 aa2e'=8015MB;16387;18435;0;20484 'D:\ Label:  Serial Number XA22aa2e'=8015MB;16387;1 8435;0;20484) processing ...
        2006-11-01 10:23:15 [3765] Turn 1 "'C:\ Label:  Serial Number bc22aa2e'=8015MB;16387 ;18435;0;20484"
        2006-11-01 10:23:15 [3765] Turn 2 "D:\ Label:  Serial Number XA22aa2e'=8015MB;16387; 18435;0;20484"
        2006-11-01 10:23:15 [3765] /usr/bin/rrdtool update /var/local/pnp-perfdata/localhost /Fake_check_snmp_storage.rrd 1162372995:8015:8015

I create a patch against pnp 0.2.4 pnp-0.2.4-label-with-spaces.patch , which correct this problem:

      2006-11-01 10:33:20 [4672] found Performance Data for localhost / Fake check_snmp_storage ( 'C:\ Label:  Serial Number bc22aa2e'=8015MB;16387;18435;0;20484 'D:\ Label: Serial NumberXA22aa2e'=8015MB;16387;18435;0;20484 )
      2006-11-01 10:33:20 [4672] Searching Custom Template for check_snmp_storage
      2006-11-01 10:33:20 [4672] No Custom Template found for check_snmp_storage
      2006-11-01 10:33:20 [4672] Template is check_snmp_storage.php
      2006-11-01 10:33:20 [4672] RRD Data Type = GAUGE
      2006-11-01 10:33:20 [4672] Perfdata is valid ('C:\ Label:  Serial Number bc22aa2e'=8 015MB;16387;18435;0;20484 'D:\ Label:  Serial Number XA22aa2e'=8015MB;16387;18435;0; 20484)
      2006-11-01 10:33:20 [4672] Turn 1 "'C:\ Label:  Serial Number bc22aa2e'=8015MB;16387 ;18435;"
      2006-11-01 10:33:20 [4672] Turn 2 "'D:\ Label:  Serial Number XA22aa2e'=8015MB;16387 ;18435;"
      2006-11-01 10:33:20 [4672] /usr/bin/rrdtool create /var/local/pnp-perfdata/localhost /Fake_check_snmp_storage.rrd --step 60 DS:1:GAUGE:8640:U:U  DS:2:GAUGE:8640:U:U  ...
      2006-11-01 10:33:20 [4672] rrdtool create returns 0

Pnp 2.4 and unit base

The graphic could containing 34kMB, which means 34GB. The plugin sent the data with a specified UOM (unit of measurement), see the Nagios plug-in develepment guidlines . The data will be stored in this form. With my pnp-0.2.4-common-unit.patch, the data will be converted to a base (eg. from MB to Bytes) and this data will be stored in the database. Now, the RRD render the graphic with correct values and units.

PNP and changed DS in RRD

If the performancedata changed the count of performance data, then the update of RRD fails. RRD cannot change the count of data sources (DS). Munin creates for each value an own RRD. What should be done in PNP? One way could be a rrd dump and a xml modification of the data, see Newsgroup article

Related content
Document Actions