Default Performance Data Options


Important: Nagios can be configured to use different methods for processing performance data. This documentation describes how to configure performance data processing if you've compiled Nagios with support for default performance data data routines (i.e. using the --with-default-perfdata argument to the configure script).


Introduction

When you compile Nagios with this performance data option, you have the ability to define commands that get executed to process performance data after each host and/or service check. This is the most flexible method for processing performance data, although it requires a good deal of system overhead, since a new process must be spawned to run the commands you define.

If you're simply planning on dumping performance data out to one or more files for later processing, I would recommend that you compile and configure Nagios to use the file-based method instead. Writing performance data directly to one or more files will be much faster and will consume much less system overhead that the default method (which requires spawning a new process to handle the data).

Processing Host Performance Data

If you want to process host performance data, you need to add a host_perfdata_command directive to your main config fileas follows:

host_perfdata_command=<command_name>

This directive is used to specify a command that should be run after every host check to process the performance data. An example entry in your main config file might look like this:

host_perfdata_command=process-host-perfdata

The name of the command that you specify in the host_perfdata_command directive must be a valid command that you've defined in your object config file. In the command definition, you can use any macros that are valid in host performance processing commands.

An example command definition that simply appends host performance data (last host check time, execution time, performance data, etc.) to a file is shown below. The various performance data items are written to the file in tab-delimited format.

define command{
	command_name	process-host-perfdata
	command_line	/bin/echo -e "$LASTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$STATETYPE$\t$EXECUTIONTIME$\t$OUTPUT$\t$PERFDATA$" >> /usr/local/nagios/var/host-perfdata
	}

Processing Service Performance Data

If you want to process service performance data, you need to add a service_perfdata_command directive to your main config file as follows:

service_perfdata_command=<command_name>

This directive is used to specify a command that should be run after every service check to process the performance data. An example entry in your main config file might look like this:

service_perfdata_command=process-service-perfdata

The name of the command that you specify in the service_perfdata_command directive must be a valid command that you've defined in your object config file. In the command definition, you can use any macros that are valid in service performance processing commands.

An example command definition that simply appends service performance data (last service check time, execution time, check latency, performance data, etc.) to a file is shown below. The various performance data items are written to the file in tab-delimited format.

define command{
	command_name	process-service-perfdata
	command_line	/bin/echo -e "$LASTCHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$STATETYPE$\t$EXECUTIONTIME$\t$LATENCY$\t$OUTPUT$\t$PERFDATA$" >> /usr/local/nagios/var/service-perfdata
	}

Optimization Notes

If you are using the service_perfdata_command directive and you are also obsessing over services, you may way to disable the obsess_over_services option and make your service_perfdata_command do double duty. Since the ocsp_command and service_perfdata_command commands are both executed after every service check, you'll cut out a bit of overhead by consolidating everything into the service_perfdata_command.