我和nagios和NRPE有个问题,我无法解决。
我已经试过了。
# grep "nrpe_user=" /etc/nagios/nrpe.cfg
nrpe_user=nrpenrpe正在以用户NRPE的身份运行。所以我在visudo中添加了这一行:
Defaults:nrpe !requiretty
nrpe ALL=(ALL) NOPASSWD: /usr/lib64/nagios/plugins/check_jboss_files我编辑了我的nagios nrpe.cfg:
command[check_jboss_files]=sudo /usr/lib64/nagios/plugins/check_jboss_files但是,如果我试图从Nagios服务器运行该命令,则会得到以下信息:
# /usr/lib64/nagios/plugins/check_nrpe -H 1.2.3.4 -c check_jboss_files
NRPE: Unable to read output在本地启动时,即使是以用户nrpe的身份运行,脚本也按预期运行:
# sudo sudo -s -u nrpe
bash-4.2$ sudo /usr/lib64/nagios/plugins/check_jboss_files
JBOSS Files: 2049
WARNING - JBOSS Files: 2049如果没有sudo,脚本将在nagios服务器上运行,但必须使用sudo才能获得良好的结果。我错过了什么?我可能什么都试过了,我会很感激你的帮助。
发布于 2018-05-04 11:29:34
最近我遇到了一个非常类似的情况,解决方案是配置selinux以允许sudo访问。
跟着这的文章,你会发现该怎么做。
对我来说,这在CentOS 7.4上起了作用:
yum install -y setroubleshoot-server我的违规行为:
$ grep -m 1 type=AVC.*sudo /var/log/audit/audit.log | audit2why
type=AVC msg=audit(1525359549.889:211763): avc: denied { getattr } for pid=127488 comm="check_d" path="/usr/bin/sudo" dev="dm-0" ino=67120340 scontext=system_u:system_r:nrpe_t:s0 tcontext=system_u:object_r:sudo_exec_t:s0 tclass=file
Was caused by:
The boolean nagios_run_sudo was set incorrectly.
Description:
Allow nagios to run sudo
Allow access by executing:
# setsebool -P nagios_run_sudo 1运行建议的命令解决了我的问题。
https://serverfault.com/questions/874050
复制相似问题