October 23, 2005

Troubleshooting "NRPE: Command 'check_disk' not defined" errors

NRPE is an indispensible part of many Nagios-based monitoring solutions, however the sample NRPE config file -- though well documented -- doesn't mention the in's and out's of all of its options.

The Nagios Remote Plugin Executor (NRPE) allows you to execute local plugins on remote hosts, then return the results of those checks to Nagios. The most common application of NRPE is to retrieve disk usage without the use of SNMP. Another common one is proxying results back from systems behind a firewall, without using passive checks.

In short, if the include parameter is set (to include definitions from an external config file), the external config file specified must exist. If it doesn't exist:

  • none of the check commands from the "internal" config file will be parsed at all
  • NRPE will return non-OK status

The transaction will look something like this:

mon> check_nrpe -H target-host -c check_users
NRPE: Command 'check_users' not defined

This isn't correct, since check_users is defined in nrpe.cfg. There isn't any interesting information to be had from the calling or target host's syslog, at least without enabling debug. If debug is enabled on the target host, the following message will be output to syslog:

Oct 21 11:02:37 target-host nrpe[25992]: Unable to open config file 'local.cfg' for reading

This more or less sums up the problem. As soon as we create the file, everything works again, even if the file is empty.

In our case, we have our clients pull Nagios plugins from an rsync server. This pull includes the nrpe.cfg file, which is great for round-the-board updates. However, we wanted to leave a place for having checks defined only for a particular host (without other hosts even knowing about them), preferrably a file that we could configure rsync to ignore. We thought that include would suit our needs based on the config file comments.

# INCLUDE CONFIG FILE
# This directive allows you to include definitions from an external config file
#include=<somefile.cfg>

# INCLUDE CONFIG DIRECTORY
#include_dir=<somedirectory>

Due to this experience, we now use the include_dir option instead. It reads in any files with a *.cfg extension, recursively from that directory down. For now, we simply have rsync push the directory but not the files within it (using --exclude). More testing will have to be done to see if include_dir is similarly affected, but it's now a non-issue for our implementation.

Posted by alexm at October 23, 2005 09:23 AM.
Send comments/suggestions to contact@moundalexis.com.
Add to del.icio.us | Digg this | Subscribe to this feed
Comments