====== NPCD ====== NPCD (Nagios-Perfdata-C-Daemon) was written to provide an asynchronous mode to handle performance data with ''nagios''. ===== Introduction ===== 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 [[pnp::config::#bulk_mode|Bulk Mode]] which gathers performance data for some time and then lets the ''nagios core'' execute the ''_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 [[pnp::modes::#bulk_mode|Bulk Mode]]. ===== Advantages / Disadvantages ===== **Pro:** * Performance improvements for nagios * Because the performance data processing is detached from the ''nagios core'' it has more time for its own work. * No lost data * as long as ''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:** * No real time processing of performance data * since there is a delay in writing the performance data files by ''nagios'' (''service_perfdata_file_processing_interval'') * another delay exists within NPCD which waits for up to 10 seconds after each directory scanning ====== NPCD Config ====== 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/nagios/bin/npcd -f /usr/local/nagios/etc/pnp/npcd.cfg or /usr/local/nagios/bin/npcd -d -f /usr/local/nagios/etc/pnp/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. ===== npcd.cfg-sample ===== 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 ===== The directives ===== * **Privilege Options** * user * NPCD tries to drop 'root' privileges to switch to this user. * **default:** nagios * group * NPCD tries to drop 'root' privileges to switch to this group. * **Default:** nagios * **Logging Options** * log_type or * Log type that is uses by NPCD * **Default:** syslog * log_file * if ''log_type = file'' this will be the logfile used * **Default:** /usr/local/nagios/var/npcd.log * max_logfile_size * NPCD will rotate the logfile if the filesize of the current log is above this limit * **Default:** 10485760 = 10 MByte * log_level * 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 * The directory where the perfdata file should be found * **Default:** /usr/local/nagios/var/perfspool/ * perfdata_file_run_cmd * This is the script/binary that NPCD will execute * **Default:** /usr/local/nagios/libexec/process_perfdata.pl * perfdata_file_run_cmd_args