New in PNP 0.6.x

PNP 0.6.x Preview

The work on the new version 0.6.x is in full progress.

Starting with version 0.6.x we switch from subversion to GIT. The sourcecode is already available on sourceforge.

Functions implemented already

back to contents | system requirements

About PNP

→ Read more...

The art of collecting data

PNP supports several modes to process performance data. The modes differ in complexity and the performance to be expected.

The following image shows the connections between Nagios, PNP and RRDtool

Nagios invokes a command for every host and every service whose performance data should be processed. Depending on the mode you choose the data will be passed to process_perfdata.pl or will be written to temporary files and processed at a later time. process_perfdata.pl writes the data to XML files and stores them in RRD files using RRDtool.

Before you choose a mode please read the documentation and decide which way will be the best for installation.

→ Read more...

PNP 0.6.x Downloads

→ Read more...

Upgrade to version 0.6.x

The web-frontend has been completely rewritten and is now based on the PHP MVC framework Kohana. This leads to changed dependencies which must be checked prior to installation.

Note: At first an upgrade is like a new installation. Afterwards some changes should be made which are described further down.

Without specifying any options during ./configure PNP 0.4.x was installed below an existing Nagios-Installation at /usr/local/nagios.

Without specifying any options during ./configure PNP 0.6.x will be installed in a separate directory at /usr/local/pnp4nagios, i.e. it should be viewed as an independent application.

Note: It is sufficient to copy the *.rrd files from the old to the new location. They contain the data The *.xml files are recreated every time new performance data arrives as they contain meta information. The internal structure of the xml files has changed so you wouldn't be able to use them either way.

→ Read more...

Installation

The installation of PNP will be described in more detail. It is expected that nagios was compiled from source and is located in /usr/local/nagios.
Attention: The description applies to the developer version PNP 0.6.0.
Please note that PNP has to be configured after the installation.

→ Read more...

Configuration

The configuration of the already mentioned modes of performance data processing will be described in more detail.

→ Read more...

Checking the installation

If everything went well until now you can try to call PNP using your web browser. When using the installation with default values PNP should be called using http://<server name>/pnp4nagios/. The first time you will see a page “PNP4Nagios Environment Tests” which includes different checks of necessary components. Obviously all checks have to be passed successfully before you can proceed. Please follow the instructions given on that page.

If all tests have passed *successfully* the file pnp4nagios/share/install.php can be deleted or renamed. Not till then the web interface is reachable.

Alternatively you can create a file called pnp4nagios/share/install.ignore which will prevent the call of the installer after further updates.

If you receive the message “PHP magic_quotes_gpc is deprecated” then please locate your php.ini and set the value to Off.

Called without any arguments PNP looks for RRD and XML files in pnp4nagios/var/perfdata and shows all graphs of the first host.

ATTENTION: Immediately after (re-)starting Nagios after you enabled the processing of performance data you will get error messages in your browser because performance data has to be collected and stored in RRD files. Depending on the check interval you are using you have to wait some time before you can view the first graphs.

→ Read more...

verify_pnp_config

In case of problems there is a script called verify_pnp_config.pl located in the scripts directory. It enables you to check the configuration settings as well as performance data of hosts or services. It can be used prior and during runtime of PNP.

* Note *: The information applies to verify_pnp_config v0.1.24 which is available in the current stable version downloadable via http://www.pnp4nagios.org/pnp/dwnld. Older versions may have fewer options so in the descriptions of the various options you will find hints to the PNP versions.

* Note *: In PNP 0.6.4 one line is missing in the script which results in an error so please add this line before executing it:

     $CPcfg{'$conf[\'max_age\']'} = 'n;^\(?[\d\* ]+\)?$';
     $CPcfg{'$conf[\'temp\']'} = 'd;;';
     $CPcfg{'$conf[\'base_url\']'} = "S;.+;";   # <-- add this line
     $CPcfg{'$conf[\'nagios_base\']'} = "S;.+;";
     $CPcfg{'$conf[\'allowed_for_service_links\']'} = 'S;[\S,]+;';

* Note *: The “long” options always start with two ”-” which isn't clearly visible in the text.

Checking the configuration can be done executing

./verify_pnp_config.pl -m <mode>

replacing <mode> by sync, bulk or NPCD.

Specifying the option -h or –-help respectively shows the following lines:

-h, --help        print these lines
-b, --basedir=s   Nagios Base directory (default: /usr/local/nagios)
-B, --binary=s    Nagios binary (default: nagios)
-c, --config=s    Nagios main config file (default: /usr/local/nagios/etc/nagios.cfg)
-m, --mode=s      PNP mode ("sync", "bulk", "NPCD")
-l, --logfile=s   check configure log file
-D, --pnpdir=s    PNP root dir (PNP version >= 0.6)
-N, --npcdcfg=s   PNP config file for NPCD mode (default: /usr/local/pnp4nagios/etc/pnp/npcd.cfg)
-P, --ppcfg=s     process_perfdata config file (default: /usr/local/pnp4nagios/etc/pnp/process_perfdata.cfg)
-C, --cpcfg=s     PNP config file (config.php)
-p, --precheck    use config files instead of objects cache
-r, --rrdtool=s   specify the location of the RRDtool binary
-R, --RRDpath=s   specify the perfdata directory (default: /usr/local/pnp4nagios/var/perfdata) or "no" for no check
-U, --resource=s  location of the resource config file (default: /usr/local/nagios/etc/resource.cfg)
-M, --monitor=s   specify the monitoring product (default: nagios; may be "icinga")
-L, --layout=s    specify a layout (Nagios2, Nagios3, SuSE, Fedora)
-T, --template=s  specify the path to the templates directory (default /usr/local/pnp4nagios/share/templates.dist)
-u, --user=s      user of the perfdata directory
-g, --group=s     group of the perfdata directory 	
-q, --quiet       quiet mode, non-zero return code will indicate errors
-o, --object=s    Nagios object (host name, service description)
-t, --time        show warnings if RRDfiles are too old
-s, --skip        skip check of installed packages
-n, --native      show messages in native language (so far "es" or "de")
-e, --english     show english messages/links
-d, --debug       some debugging output
-I, --info        show information about compile time variable settings

The Nagios program and access to the main configuration file are always necessary. If you have non-standard paths because you installed a Nagios package you can try to use one of the predefined layouts via the -L option. “suse” and “fedora” should work on the appropriate distributions while “nagios2” and “nagios3” should work on others depending on the Nagios version you installed. If none of these methods work you can use three options (-b, -B and -c) to specify the nagios base directory, the name of the binary and the place of the main config file. If the program name starts with a ”/” then this value is taken as an absolute path which isn't modified anymore. If it doesn't start with a ”/” then the path is composed of the basedir, the string “bin” and the binary. Using -U you can specify the location on the resource config file.

Without specifying any options the help page will be shown so you'll have to specify either the mode or an object.

Using the option -m (–mode) you specify one of the PNP modes whose settings will be checked. The option -l <filename> (–logfile=<filename>) allows to check the config during installation of PNP. You have to execute ./configure (with additional options if necessary) first which creates the file config.log. This name has to be passed as parameter value. The script checks if software requirements are met and if several settings have been specified correctly. That includes a call of the RRDtool binary so you may use the option -r <location> (–rrdtool <location>) if the binary can not be found at /usr/bin/rrdtool.

The script checks if owner and group of the directories and files below the perfdata folder correspond to the values given in nagios.cfg. Additionally the xml files are checked for non-zero return codes of RRDtool. Using the option -R (–RRDpath) you can specify the directory where the RRD files are located if its place is non-standard. If you don't wish these checks to be performed please specify “no” as directory name. Using the options -u (–user) and -g (–group) you can specify user and/or group of the perfdata directory if they don't match the values of the nagios user.

After the installation the changes in nagios.cfg can be checked using the option -p (–precheck) before restarting nagios. This way you can correct any errors without restarting every time.

Together with the option -o <object> (–object=<object>) you specify a string which is compared to hostnames and/or service descriptions in the objects cache file. The string should be enclosed in quotes to escape blanks and several special characters. If the string matches the name and any performance data will be shown. If no or invalid performance data is present appropriate messages will be given.

Appending a semicolon to the string will result in comparing only hostnames, prepending a semicolon only inspects service descriptions. A semicolon within the string separates hostname and service description.

Starting with PNP version 0.6 the directory layout has changed so all files are below a separate directory which can be specified using ”-D” (–pnpdir) if it differs from /usr/local/pnp4nagios. This also affects the options ”-N”, ”-P” and ”-C”, respectively, so you may not have to specify separate values for these options.

When using the NPCD mode you can use -N <config file> (–npcdcfg=<config file>) to specify the location of the config file if its name or location differs from the default (/usr/local/pnp4nagios/etc/npcd.cfg).

Using the option -P <config file> (–ppcfg=<config file>) you can specify the name of the config file for process_perfdata.pl if name or location differs from the default (/usr/local/pnp4nagios/etc/process_perfdata.cfg).

Using the option -M (–monitor) enables you to specify the product which delivers the data to PNP. The default is “nagios” but “icinga” is supported now as well. Additionally you may have to use the options -b, -B and -c as well.

Sometimes changes in template files result in errors which are hard to find in the web GUI. Using the option -T the template files are checked for errors. Specify the path to the templates diretory as a parameter.

Per default the script checks if certain packages are installed. If you experience difficulties with these checks (or when you're sure the required packages are installed) you can use the option -s (–skip) to skip these checks.

Using -n (–native) you can specify “es” or “de” to see spanish or german messages, respectively.

The option -e (–english) enables you to force the use of english messages if the script detects german language settings.

The option -d (–debug) will output additional lines which may help during trouble shooting whereas -q (–quiet) suppresses all output. Errors will result in a non-zero return code.

The option -I (–info) shows the settings of variables like prefix, datadir and other things you might have changed during './configure'. In some cases we need to know these values and using this option is easier than searching different files. The option is available starting with PNP 0.6.7.

Each output line will start with a letter indicating the type of information:

[I] informational message about settings, things to be done, …
[A] actions to be taken
[W] warning message
[E] error message: PNP will not work without resolving the problem(s)
[H] hint: it might be worth reading the appropriate documentation
[D] debugging message, hopefully showing the source of your problem

back to contents | web frontend

Nagios web frontend

Of course PNP should be easily accessible. You do not want to search long for the right graph.

Nagios itself features external URLs using so called extended info configs. Due to changes between Nagios 2.x and Nagios 3.x both versions are described.

→ Read more...

PNP Web Frontend

The behaviour of the PNP Web-Frontend can be controlled through the config file etc/config.php. This file will be overwritten during updates of PNP as the paths and options are detected during ./configure.

Own adjustments should be made in etc/config_local.php. If this file does not exist the file config.php can be taken as a guideline.

→ Read more...

Timeranges

In the overview PNP shows five timeranges which can be defined in config.php.

Additionally you can influence the timeranges via the URL. This can be useful to automatically create PDF documents. The ranges can be defined using the options “start” and “end”.

Example:

 pnp4nagios/graph?host=<hostname>&srv=<servicedesc>&start=-1week

The graph will start one week prior to the current date and time. It will end at the current timestamp.

start end view result
all views ending at current timestamp
x all views starting at defined date
x all views ending at defined date
x x one view between the two dates
x one view ending at current timestamp
x x one view starting at defined date
x x one view ending at defined date

Examples of different specifications

format description
2009W04 4. week of 2009
1.5.2009 May, 1st 2009
-1 day one day back
-3 weeks 3 weeks back
-1 year one year back
yesterday yesterday

back to contents | pages

Pages

“pages” provide the opportunity to collect graphs of different hosts/services on one page. That way - as an example - you can display the traffic rates of all tape libraries. Regular expressions are possible so you can accomplish a lot with only few definitions - provided that you have appropriate names. The directory specified using “$conf['page_dir']” contains one or more file with the extension ”.cfg”.

Comments start with a hash-sign (#) and are possible within lines as well. Each file contains a “page” definition which specifies the name of the page and it determines whether the following graph definition contains regular expressions or not.
The description behind page_name appears in the list of available pages and will be used as title of the browser window. Attention: “host_name” and “service_desc” refer to the name of the file in the perfdata directory, not to the definition in Nagios. Blanks are replaced by underscores (_).

define page {
       use_regex 1		# 0 = use no regular expressions, 1 = use regular expressions
       page_name test-page	# page description
}

One or more “graph” definitions follow:

define graph {
       host_name       host1,host2,host3
       service_desc    Current_Load
}

Attention: The list of host name will only work if you use regex 0!

define graph {
       host_name       host4
       service_desc    Current_Users
}

And now some definitions with regular expressions. At first all hosts whose names are starting with “Tape”:

define graph {
       host_name       ^Tape
       service_desc    Traffic
}

all hosts whose names are ending with “00”:

define graph {
       host_name       00$
       service_desc    Load
}

all services of localhost whose names contain “a” or “o”, respectively:

define graph {
       host_name       localhost
       service_desc    a|o
}

all services whose names contain an underscore followed by (at least) three digits on all hosts whose names start with “UX”:

define graph {
       host_name       ^UX
       service_desc    _\d{3}
}

back to contents | data export

Data export

PNP provides access to RRD data using the xport controller. The output format can be specified. At the moment the formats xml, json and csv are supported.

The controller can be called using the URL

/pnp4nagios/xport/<format>?host=<hostname>&srv=<servicedesc>

whereas <format> has to be replaced with the desired format.

back to contents | templates

What are templates?

PNP uses templates to influence the appearance of RRD graphs.

The selected check_command determines which template will be used to control the graph. Following will be described where templates are stored and how the decision for the “right” template is made.

→ Read more...

Custom Templates

As already described under ”What are templates ?” the appearance of graphs depends on the check command used.

There are situations where this behaviour must be overruled. This has to be done when universal commands have been defined.

→ Read more...

Distributed Systems

If Nagios is implemented as a distributed system you have to decide where PNP should be installed.

From a technical view this question is not important. PNP can be installed on the slave(s) as well as on the master server. Or only on the master?

If PNP is running on the master you have to make sure that data passed via send_nsca from the slave server(s) contains performance data. Often another check command is used on the master.

To help PNP on the master to recognize which check command was used on the slave to collect the information process_perfdata.pl responds to an additional field at the end of the performance data.

OK - 127.0.0.1: rta 2.687ms, lost 0% | rta=2.687ms;3000.000;5000.000;0; pl=0%;80;100;; [check_icmp]

If PNP finds a string enclosed in brackets at the end of performance data it will be recognized as check command and will be used as PNP template.

Nagios documentation related to this topic can be found here. The command used in the documentation can be adapted easily.

define command{
	command_name	submit_check_result
	command_line	/usr/local/nagios/libexec/eventhandlers/submit_check_result $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATE$ '$SERVICEOUTPUT$'
	}

should be changed to

define command{
	command_name	submit_check_result
	command_line	/usr/local/nagios/libexec/eventhandlers/submit_check_result $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATE$ '$SERVICEOUTPUT$ | $SERVICEPERFDATA$ [$SERVICECHECKCOMMAND$]'
	}

→ Read more...

RRDtool Cache Daemon

In large installations sooner or later one will recognize that processing the performance data will result in a relatively high I/O load. RRDtool has to do very much disk updates but cannot use the disk cache in an optimal way.

One improvement is made by collecting and sorting the data. It is more effective to write many updates to an RRD database in one block. The disk cache can be used more effectively that way.

The current RRDtool ( SVN trunk 1550+ ) contains rrdcached which should improve exactly this situation.

At this point I'd like to thank Florian octo Forster, Kevin Brintnall and Tobi Oetiker. The development of this daemon has been coordinated exemplary on the rrd-developers mailing list.

→ Read more...

NPCD

NPCD (Nagios-Perfdata-C-Daemon) was written to provide an asynchronous mode to handle performance data with nagios.

→ Read more...

check_procs is an example for a plugin which doesn't deliver performance data:

./check_procs -a ndo2db -w 1: -c 0:
PROCS OK: 2 processes with args 'ndo2db'

This can be changed with the following wrapper script

check_procs.sh

#!/bin/bash
LINE=`/usr/local/nagios/libexec/check_procs $*`
RC=$?
COUNT=`echo $LINE | awk '{print $3}'`
echo $LINE \| procs=$COUNT
exit $RC

Now you'll get the number together with the required label

./check_procs.sh -a ndo2db -w 1: -c 0:
PROCS OK: 2 processes with args 'ndo2db'| procs=2

2.6. Performance data

Performance data is defined by Nagios as “everything after the | of the plugin output” - please refer to Nagios documentation for information on capturing this data to logfiles. However, it is the responsibility of the plugin writer to ensure the performance data is in a “Nagios plugins” format. This is the expected format:

'label'=value[UOM];[warn];[crit];[min];[max]

Notes:

  1. space separated list of label/value pairs
  2. label can contain any characters
  3. the single quotes for the label are optional. Required if spaces, = or ' are in the label
  4. label length is arbitrary, but ideally the first 19 characters are unique (due to a limitation in RRD). Be aware of a limitation in the amount of data that NRPE returns to Nagios
  5. to specify a quote character, use two single quotes
  6. warn, crit, min/ or max/ may be null (for example, if the threshold is not defined or min and max do not apply). Trailing unfilled semicolons can be dropped
  7. min and max are not required if UOM=%
  8. value, min and max in class [-0-9.]. Must all be the same UOM
  9. warn and crit are in the range format (see Section 2.5). Must be the same UOM
  10. UOM (unit of measurement) is one of:
    • no unit specified - assume a number (int or float) of things (eg, users, processes, load averages)
    • s - seconds (also us, ms)
    • % - percentage
    • B - bytes (also KB, MB, TB, GB?)
    • c - a continous counter (such as bytes transmitted on an interface)

It is up to third party programs to convert the Nagios plugins performance data into graphs.

Origin: http://nagiosplug.sourceforge.net/developer-guidelines.html#AEN201