不确定如何解决 NRPE 问题

Unsure how to troubleshoot NRPE issue

如果已分发 Nagios 的 puppet 检查可从 https://github.com/liquidat/nagios-icinga-checks/blob/master/check_puppetagent

我的问题是,如果我在本地执行与通过 NRPE 执行,我会得到不同的结果:

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

[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.

正在编辑文件 /usr/lib64/nagios/plugins/check_puppetagent 并将行更改为: summary = '/opt/puppetlabs/puppet/cache/state/last_run_summaries.yaml' 在客户端上产生预期结果:

[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.

所以我知道正在执行正确的文件。

从远程工作手动执行:

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

Antone 有任何问题 ideas/suggestions 我还能做些什么来解决问题?

last_run_summaries.yaml 似乎只能由 root 读取: https://projects.puppetlabs.com/issues/7106

当您从命令行 运行 check_puppetagent 时,表明您正在 运行 宁作为 root。但是 NRPE 可能是 运行ning check_puppetagent 作为 nagios 用户。

尝试修改您的 nrpe 命令配置以在 check_puppetagent 之前调用 sudo 并修改您的 /etc/sudoers 文件以授予 nagios 用户权限运行 check_puppetagent 作为 root.

编辑: 另外一定要注释掉 /etc/sudoers 文件中的 Defaults requiretty

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