Documentation Version 0.6.42

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 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

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/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.

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/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

The directives

  • 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>
      • if log_type = file this will be the logfile used
      • Default: /usr/local/pnp4nagios/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/pnp4nagios/var/spool/
    • perfdata_file_run_cmd </path/to/bin/filename>
      • This is the script/binary that NPCD will execute
      • Default: /usr/local/pnp4nagios/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>
      • if use_load_threshold is 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

back to contents | wrapper script

pnp4nagios-0.6.42 [ 04-17-2023 ]