Table of Contents
NPCD (Nagios-Perfdata-C-Daemon) was written to provide an asynchronous mode to handle performance data with
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.
How it works
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.
Advantages / Disadvantages
- Performance improvements for nagios
- Because the performance data processing is detached from the
nagios coreit has more time for its own work.
- No lost data
- as long as
nagioswrites 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.
- No real time processing of performance data
- since there is a delay in writing the performance data files by
- another delay exists within NPCD which waits for up to 10 seconds after each directory scanning
You have to control NPCD with its own configuration file like the rolled out
Just rename it to
npcd.cfg to start NPCD like this:
<code_bash>/usr/local/nagios/bin/npcd -f /usr/local/nagios/etc/pnp/npcd.cfg</code> or <code_bash>/usr/local/nagios/bin/npcd -d -f /usr/local/nagios/etc/pnp/npcd.cfg</code> 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/nagios/var/npcd.log max_logfile_size = 10485760 log_level=0 # Processing Options perfdata_spool_dir = /usr/local/nagios/var/spool/perfdata/ perfdata_file_run_cmd = /usr/local/nagios/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
- Privilege Options
- user <username>
- NPCD tries to drop 'root' privileges to switch to this user.
- default: nagios
- group <groupname>
- NPCD tries to drop 'root' privileges to switch to this group.
- Default: nagios
- Logging Options
- log_type <syslog> or <file>
- Log type that is uses by NPCD
- Default: syslog
- log_file </path/to/filename>
log_type = filethis will be the logfile used
- Default: /usr/local/nagios/var/npcd.log
- max_logfile_size <bytes>
- NPCD will rotate the logfile if the filesize of the current log is above this limit
- Default: 10485760 = 10 MByte
- log_level <integer>
- how much to log, possible values:
- 0 = No Log - except errors
- 1 = small Log - some more output
- 2 = more Log (actual ALL log messages)
- -1 = DEBUG Mode - ALL Logs and slower processing for debugging purposes
- Default: 0
- Processing Options
- perfdata_spool_dir </path/to/spool/dir/>
- The directory where the perfdata file should be found
- Default: /usr/local/nagios/var/perfspool/
- perfdata_file_run_cmd </path/to/bin/filename>
- This is the script/binary that NPCD will execute
- Default: /usr/local/nagios/libexec/process_perfdata.pl
- perfdata_file_run_cmd_args <option>
- The argument added to the perfdata_file_run_cmd
- Default: “-b”
- The command line will be created like this:
<perfdata_file_run_cmd> <perfdata_file_run_cmd_args> <filename_from_perfdata_spool_dir>
- Thread Options
- npcd_max_threads <integer value>
- Defines how many parallel threads should be started
- Default: 5
- Greedy Options
- use_load_threshold <0 or 1>
- defines if NPCD should _not_ start new threads if your system load is too high
- 0 = disable
- 1 = enable
- Default: 0
- load_threshold <float value>
use_load_thresholdis set to 1 this load limit must not be exceeded
- Default: 10.0
- Process Options
- pid_file </path/to/pid.file>
- the path to the PID File
- Default: /var/run/npcd.pid