NRPE: Unable to read output 问题处理总结
自定义nagios监控命令check_disk_data,首先在nagios服务端command.cfg定义了
#'check_disk_data' command definition
define command {
command_name check_disk_data
command_line /usr/local/nagios/libexec/check_disk_data -H $HOSTADDRESS$
}
在nagios服务端执行命令,返回NRPE:Unable to read output
[root@192.168.10.5_监控服 ]$ /usr/local/nagios/libexec/check_nrpe -H 192.168.10.8 -c check_disk_data
NRPE: Unable to read output
[root@192.168.10.5_监控服 objects]$ /usr/local/nagios/libexec/check_nrpe -H 192.168.10.8
NRPE v2.14
可以返回nrpe版本信息,说明nrpe通信正常
被监控端 check_disk_data 的定义: /usr/local/nagios/etc/nrpe.cfg
command[check_disk_data]=/usr/bin/sudo /usr/local/nagios/libexec/check_disk_data
脚本路径没有错,同时拥有执行权限。经过认真排查,应该编辑/etc/sudoers文件
修改以下几个点即可:
#Defaults requiretty # sudo不允许后台运行,注释此行即允许
Defaults visiblepw # sudo不允许远程,去掉!即允许
root ALL=(ALL) ALL
nagios ALL=(ALL) NOPASSWD:ALL
%wheel ALL=(ALL) ALL
%wheel ALL=(ALL) NOPASSWD: ALL