Skip to content

Nagios

This guide covers monitoring Nagios check plugins that run on a schedule. Pakyas verifies that each check executed and completed as expected.

Install on the Nagios server or the host running NRPE. The examples below use /usr/local/bin/pakyas, so install system-wide as root:

Terminal window
curl -fsSL https://pakyas.com/install.sh | sudo PAKYAS_INSTALL_DIR=/usr/local/bin sh

Match the check’s interval to the Nagios check_interval:

Terminal window
pakyas check create disk-usage --every 5m

The examples below use the slug, which needs PAKYAS_API_KEY in the environment of the Nagios (or NRPE) process. Nagios usually doesn’t read login profiles, so it is simpler to use the check’s public ID instead, which needs no key:

command_line /usr/local/bin/pakyas monitor --public-id 550e8400-e29b-41d4-a716-446655440000 -- /usr/lib/nagios/plugins/check_disk -w 20% -c 10%
Section titled “Option A: Wrap the check command (Recommended)”

Modify your Nagios command definition to wrap the check with Pakyas:

/etc/nagios/objects/commands.cfg
define command {
command_name check_disk_pakyas
command_line /usr/local/bin/pakyas monitor disk-usage -- /usr/lib/nagios/plugins/check_disk -w 20% -c 10%
}
/etc/nagios/objects/services.cfg
define service {
use generic-service
host_name localhost
service_description Disk Usage
check_command check_disk_pakyas
check_interval 5 ; runs every 5 minutes
}

For checks running on remote hosts via NRPE, install Pakyas on the remote host and wrap the command in the NRPE config:

# /etc/nagios/nrpe.cfg on remote host
command[check_disk]=/usr/local/bin/pakyas monitor disk-usage -- /usr/lib/nagios/plugins/check_disk -w 20% -c 10%

Name checks by what they verify, not the tool:

GoodBad
disk-usagenagios-disk
mysql-healthcheck_mysql
backup-verifynrpe-backup
  1. Nagios schedules the check at the configured interval
  2. Pakyas sends a start signal when the check begins
  3. The check plugin runs; its output passes through to Nagios unchanged
  4. Pakyas sends success (exit 0) or failure (any non-zero exit, including WARNING = 1) to your dashboard
  5. pakyas exits with the plugin’s exit code, so Nagios sees the same status
  6. If the check doesn’t run on schedule, Pakyas alerts you

If Pakyas can’t record the run (network problem, unknown slug), pakyas monitor exits 3, which Nagios shows as UNKNOWN. The plugin still ran; its output is printed as usual.