NPCD (Nagios-Perfdata-C-Daemon) was written to provide an asynchronous mode to handle performance data with nagios
.
In large nagios installations, your average check latency may increase to a non-acceptable high value. This means that Nagios should do a check at time x
but actually does it y
seconds later.
If you tell the Nagios core that you want to process the performance data after every single check this is doing well for a certain amount of checks but above this limit you will run into latency problems.
To reduce the number of actions for each check you can use the Bulk Mode which gathers performance data for some time and then lets the Nagios core
execute the <host|service>_perfdata_file_processing_command
or you can tell Nagios to just move the perfdata_files
to a spool directory.
This move is a very fast action for the Nagios core
and the core
will be done with the processing of performance data and can continue to do what it should do: execute other checks, sending notifications, and so on.
As mentioned above the Nagios process has finished its work with moving the performance data file to a spool directory but this won't bring the data into the RRD files.
For this task you can start npcd
to have a look at the defined spool directory and start an action for every file which is found.
After NPCD starts running it will build a list of filenames found in perfdata_spool_dir
and starts new threads for every filename and executes the perfdata_file_run_cmd
with the optional perfdata_file_run_cmd_arg
as an additional argument.
Since the perfdata files in the spool dir are in the same format as for the 'normal' bulk mode NPCD should execute process_perfdata.pl
in Bulk Mode.
Pro:
Nagios core
it has more time for its own work.Nagios
writes perfdata files to the spool dir your data won't get lost if NPCD dies or you forgot to start it after a system reboot. NPCD will start with the first file found (they are sorted by the $TIME_T$ macro in chronological order) and update your RRD Files.Con:
Nagios
(service_perfdata_file_processing_interval
)
You have to control NPCD with its own configuration file like the rolled out npcd.cfg-sample
file.
Just rename it to npcd.cfg
to start NPCD like this:
/usr/local/pnp4nagios/bin/npcd -f /usr/local/pnp4nagios/etc/npcd.cfg
or
/usr/local/pnp4nagios/bin/npcd -d -f /usr/local/pnp4nagios/etc/npcd.cfg
to run in Daemon Mode (background).
Hint: If you decide to not rename the config file, it might be overwritten by a future update of PNP.
These are the essential configuration directives for NPCD:
# Privilege Options user = nagios group = nagios # Logging Options log_type = syslog log_file = /usr/local/pnp4nagios/var/npcd.log max_logfile_size = 10485760 log_level=0 # Processing Options perfdata_spool_dir = /usr/local/pnp4nagios/var/spool/ perfdata_file_run_cmd = /usr/local/pnp4nagios/libexec/process_perfdata.pl perfdata_file_run_cmd_args = -b # Thread Options npcd_max_threads=5 # greedy options use_load_threshold = 0 load_threshold = 10.0 # Process Options pid_file=/var/run/npcd.pid
log_type = file
this will be the logfile used<perfdata_file_run_cmd> <perfdata_file_run_cmd_args> <filename_from_perfdata_spool_dir>
use_load_threshold
is set to 1 this load limit must not be exceeded