Search code examples
nagiosnrpe

Unsure how to troubleshoot NRPE issue


If have distributed the puppet check for Nagios available from https://github.com/liquidat/nagios-icinga-checks/blob/master/check_puppetagent

My issue is that I get different results if I execute locally vs via NRPE:

[root@nagios-client /]# /usr/lib64/nagios/plugins/check_puppetagent
OK: Puppet was last run 17 minutes and 9 seconds ago

vs

[root@nagios ~]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.50.121 -c check_puppetagent
WARN: Puppet has never run, no /opt/puppetlabs/puppet/cache/state/last_run_summary.yaml found.

Editing the file /usr/lib64/nagios/plugins/check_puppetagent and changing the line to: summary = '/opt/puppetlabs/puppet/cache/state/last_run_summaries.yaml' on the client yields the expected result:

[root@nagios ~]# /usr/lib64/nagios/plugins/check_nrpe -H 192.168.50.121 -c check_puppetagent
WARN: Puppet has never run, no /opt/puppetlabs/puppet/cache/state/last_run_summaries.yaml found.

So I know the correct file is being executed.

Executing it manually from remote works:

[root@nagios ~]# ssh 192.168.50.121 "/usr/lib64/nagios/plugins/check_puppetagent"
[email protected]'s password:
OK: Puppet was last run 13 seconds ago

Antone have any ideas/suggestions what else I can do to troubleshoot?


Solution

  • last_run_summaries.yaml appears to only be readable by root: https://projects.puppetlabs.com/issues/7106

    When you run check_puppetagent from the command line, you're showing that you're running as root. But NRPE would likely be running check_puppetagent as the nagios user.

    Try modifying your nrpe command configuration to call sudo before check_puppetagent and modify your /etc/sudoers file to give the nagios user permissions to run check_puppetagent as root.

    EDIT: Also be sure to comment out the Defaults requiretty in your /etc/sudoers file.

    #Defaults requiretty
    nagios ALL=(ALL) NOPASSWD:/usr/lib64/nagios/plugins/check_puppetagent