Fork me on GitHub
Translations of this page:

Configuration

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

Default Mode

The default-mode is the simplest way to integrate the data collector process_perfdata.pl into nagios. Every event will trigger an execution of process-service-perfdata.

Initially you have to enable processing of performance data in nagios.cfg. Please note that this directive might already exist in the config file. Default is “0”.

 process_performance_data=1

Data processing has to be disabled in the definition of every host or service whose performance data should NOT be processed.

define service {
   ...
   process_perf_data 0
   ...
}

Since Nagios 3.x it is possible to deactivate the export of environment variables (as part of optimizing the system for maximum performance). Unfortunately this directive has to be enabled to use the default mode. So either you use the default value (which means that the export is enabled) or you define the variable in nagios.cfg

enable_environment_macros=1

Additionally the command to process performance data is to be specified in nagios.cfg

 service_perfdata_command=process-service-perfdata

Starting with Nagios 3.0 it may be useful to enable processing of performance data for hosts as well. Due to changed host check logic Nagios 3 now performs regularly scheduled host checks.

 host_perfdata_command=process-host-perfdata

Nagios has to be notified about the referenced commands as well. If you used the quickstart installation guides for Nagios you can modify the definitions in commands.cfg. You can see that calling process_perfdata.pl doesn't require any arguments apart from specifing the option -d ( DATATYPE ) if you want to process performance data resulting from host checks.

define command {
  command_name    process-service-perfdata
  command_line    /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl
}

define command {
  command_name    process-host-perfdata
  command_line    /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}

Note process_perfdata.pl cannot be started under control of ePN ( embedded Perl Nagios ). Therefore the script is explicitly called using /usr/bin/perl ( or where you perl binary is located ). If you use Nagios 3.x or do not use ePN there is no need to specify /usr/bin/perl.

Bulk Mode

Bulk mode is a bit more complicated than the default-mode but reduces the load on the nagios server significantly because the data collector process_perfdata.pl is not invoked for every service.

In bulk-mode nagios writes the data to a temporary file in a defined format. This file is processed by process_perfdata.pl at certain intervals. Nagios will take care for starting and running it periodically.

Processing of performance data has to be enabled in nagios.cfg

 process_performance_data=1

Additionally some new directives are required

#
# service performance data
#
service_perfdata_file=/usr/local/nagios/var/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=15
service_perfdata_file_processing_command=process-service-perfdata-file

#
# host performance data starting with Nagios 3.0
# 
host_perfdata_file=/usr/local/nagios/var/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$
host_perfdata_file_mode=a
host_perfdata_file_processing_interval=15
host_perfdata_file_processing_command=process-host-perfdata-file

The directives and their meaning:

  • service_perfdata_file path to the temporary file which should contain the performance data.
  • service_perfdata_file_template format of the temporary file. Data will be defined using nagios macros.
  • service_perfdata_file_mode option “a” specifies that data is to be appended to the file.
  • service_perfdata_file_processing_interval the interval is 15 seconds
  • service_perfdata_file_processing_command the command to be called during the interval.

The used commands have to be announced to Nagios. If you used the quickstart installation guides for Nagios you can modify the definitions in commands.cfg.

define command{
        command_name    process-service-perfdata-file
        command_line    $USER1$/process_perfdata.pl --bulk=/usr/local/nagios/var/service-perfdata
 }

define command{
        command_name    process-host-perfdata-file
        command_line    $USER1$/process_perfdata.pl --bulk=/usr/local/nagios/var/host-perfdata
 }

NOTE:

Because there is more data to process than in default mode process_perfdata.pl will take longer to do this so you should check the TIMEOUT value in etc/pnp/process_perfdata.cfg and adjust it appropriately.

Bulk Mode with NPCD

The configuration is identical to the Bulk-mode except for the used command. If you used the quickstart installation guides for Nagios you can modify the definitions in commands.cfg.

define command{
        command_name    process-service-perfdata-file
        command_line    /bin/mv /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/spool/perfdata/service-perfdata.$TIMET$
 }

define command{
        command_name    process-host-perfdata-file
        command_line    /bin/mv /usr/local/nagios/var/host-perfdata /usr/local/nagios/var/spool/perfdata/host-perfdata.$TIMET$
 }

Using these commands the file service-perfdata will be moved to var/spool/ after the interval specified in service_perfdata_file_processing_interval has passed. The nagios macro $TIMET$ is appended to the filename to avoid overwriting of old files unintentionally. The macro $TIMET$ contains the current timestamp in time_t format (seconds since the UNIX epoch).

In the directory /usr/local/nagios/var/spool/perfdata files are gathered to be processed by NPCD.

NPCD monitors the spool directory and passes the file names to process_perfdata.pl. This way processing of performance data is completely decoupled from nagios.

Before starting NPCD you have to check the paths to the spool directory and to process_perfdata.pl specified in the config file npcd.cfg. The only thing that remains is to start NPCD.

 /usr/local/nagios/bin/npcd -d -f /usr/local/nagios/etc/pnp/npcd.cfg

The option -d starts NPCD as a daemon in the background.

back to contents | checking the functionality

pnp-0.4/config.txt · Last modified: 2009/08/09 17:42 by Joerg Linge
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0