nagios nrpe无法读取输出

我试图使用check_nrpe检查远程服务器,但它不工作,我不知道我错过了什么…

 # /usr/lib/nagios/plugins/check_nrpe -H XXX -c check_load -a 6,5,4 8,7,6 NRPE: Unable to read output # 

远程的服务器系统日志消息:

 nrpe[18058]: Connection from XX.XX.XX.XX port 16267 nrpe[18058]: Host address is in allowed_hosts nrpe[18058]: Handling the connection... nrpe[18058]: Host is asking for command 'check_load' to be run... nrpe[18058]: Running command: /usr/bin/sudo /usr/lib64/nagios/plugins/check_load -w 6,5,4 -c 8,7,6 nrpe[18058]: Command completed with return code 1 and output: nrpe[18058]: Return Code: 1, Output: NRPE: Unable to read output nrpe[18058]: Connection from XX.XX.XX.XX closed. 

要手动validation它,我在远程shell上发出相同的命令:

 bash-4.1$ id uid=497(nrpe) gid=497(nrpe) groups=497(nrpe) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 bash-4.1$ /usr/bin/sudo /usr/lib64/nagios/plugins/check_load -w 6,5,4 -c 8,7,6 OK - load average: 0.21, 0.23, 0.19|load1=0.210;6.000;8.000;0; load5=0.230;5.000;7.000;0; load15=0.190;4.000;6.000;0; bash-4.1$ 

…问题是,尽pipenrpe_user/etc/nagios/nrpe.cfg设置为nrpe ,不pipe是什么原因, nrpe作为nagios用户运行,所以我必须重新调整sudoers.d文件,并马上开始工作…

 # grep nrpe_user /etc/nagios/nrpe.cfg nrpe_user=nrpe # ps auxwww | grep nrpe nagios 25388 0.0 0.0 41332 1240 ? Ss 11:32 0:00 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d root 26230 0.0 0.0 103252 828 pts/3 S+ 11:47 0:00 grep nrpe # cat /etc/sudoers.d/01_nagios Defaults:nagios !requiretty nagios ALL=(ALL) NOPASSWD: /usr/lib64/nagios/plugins/ # 

这可能是由于sudo的“requiretty”设置造成的。 但真正的问题是,为什么你要通过sudo运行check_load。

所以,要解决这个问题:要么禁用requiretty(只为nagios / nrpe用户),要么停止通过sudo运行插件。

在正在检查的机器上,findnrpe.cfg文件,并在其中find“check_load”条目。 它看起来像这样:

 command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 

尝试在该机器上运行命令 – 一切在上面等号的右边,看看你得到了什么。

 /usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20 

我敢打赌,它在/ usr / lib / nagios / plugins而不是/ usr / lib64或类似的东西中寻找check_load。