1

如果已分发 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 有什么想法/建议我还能做些什么来排除故障?

4

1 回答 1

0

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

当您从命令行运行check_puppetagent时,表明您正在以root身份运行。但 NRPE 可能会check_puppetagentnagios用户身份运行。

尝试修改您的 nrpe 命令配置以调用sudo之前check_puppetagent并修改您的/etc/sudoers文件以授予nagios用户以rootcheck_puppetagent身份运行的权限。

编辑:Defaults requiretty也一定要在你的/etc/sudoers文件中注释掉。

#Defaults requiretty
nagios ALL=(ALL) NOPASSWD:/usr/lib64/nagios/plugins/check_puppetagent
于 2015-11-25T03:30:55.193 回答