Nagios
This guide covers monitoring Nagios check plugins that run on a schedule. Pakyas verifies that each check executed and completed as expected.
1. Install Pakyas CLI
Section titled “1. Install Pakyas CLI”Install on the Nagios server or the host running NRPE. The examples below use /usr/local/bin/pakyas, so install system-wide as root:
curl -fsSL https://pakyas.com/install.sh | sudo PAKYAS_INSTALL_DIR=/usr/local/bin sh2. Create a Check per Plugin
Section titled “2. Create a Check per Plugin”Match the check’s interval to the Nagios check_interval:
pakyas check create disk-usage --every 5mThe 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%Wrapping Check Plugins
Section titled “Wrapping Check Plugins”Option A: Wrap the check command (Recommended)
Section titled “Option A: Wrap the check command (Recommended)”Modify your Nagios command definition to wrap the check with Pakyas:
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%}Option B: Use in service definition
Section titled “Option B: Use in service definition”define service { use generic-service host_name localhost service_description Disk Usage check_command check_disk_pakyas check_interval 5 ; runs every 5 minutes}NRPE (Remote Checks)
Section titled “NRPE (Remote Checks)”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%Check Naming
Section titled “Check Naming”Name checks by what they verify, not the tool:
| Good | Bad |
|---|---|
| disk-usage | nagios-disk |
| mysql-health | check_mysql |
| backup-verify | nrpe-backup |
How it works
Section titled “How it works”- Nagios schedules the check at the configured interval
- Pakyas sends a start signal when the check begins
- The check plugin runs; its output passes through to Nagios unchanged
- Pakyas sends success (exit 0) or failure (any non-zero exit, including WARNING = 1) to your dashboard
pakyasexits with the plugin’s exit code, so Nagios sees the same status- 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.