I have a nagios check to report puppet run success/failures. The check runs fine locally:
$ sudo -u nrpe /usr/local/nagios/libexec/check_puppet_agent
I AM: nrpe
CRITICAL: Puppet daemon not running or something wrong with process
I am echoing the output of whoami
for debugging purposes. Then I get the CRITICAL message because puppet service is stopped, that's fine. So far, so good.
However, when I run the check remotely from the nagios server, I get this:
$ /usr/local/nagios/libexec/check_nrpe -H MY-HOST -c check_puppet_agent
I AM: nrpe
UNKNOWN: last_run_summary.yaml not found, not readable
There seems to be some problem reading the filesystem. NRPE is not able to read the /var/lib/puppet
directory when run remotely, but the nrpe
user can read it fine locally. Why is this? What can be causing this error? The check is supposed to be run as the nrpe user, so why can't it read the directory?
Ok, apparently the problem was
selinux
. It was preventing processnrpe
to access the/var/lib/puppet
directory, so I had to taylor a selinux module with some rules to allow nrpe to run this check.