nrpe 执行命令报错NRPE: Unable to read output
在客户端编写的一个脚本check_ssh_auto.sh
#!/bin/bash
a=`/bin/cat /etc/ssh/sshd_config | grep PasswordAuthentication | grep -v "^#" | awk '{print $2}'`
if [ "$a" = "yes" ]; then
echo "SSH authentication: WARNING Please amend the warning SSH authentication for key authentication;"
$(exit 1)
else
echo "SSH authentication: OK;"
$(exit 0)
fi
客户端执行正常
nagios服务器测试执行
/usr/local/nagios/libexec/check_nrpe -H 192.168.10.1 -c ssh_auth
提示NRPE: Unable to read output
解决方法
在客户端修改文件
vi /etc/sudoers
注视这行
#Defaults requiretty
在root ALL=(ALL) ALL下面添加一行
nagios ALL=(ALL) NOPASSWD:/usr/local/nagios/libexec/*
修改nrpe配置文件/usr/local/nagios/etc/nrpe.cfg
command[ssh_auth]=/usr/bin/sudo /usr/local/nagios/libexec/check_ssh_auth.sh
重启nrpe
服务器端再次测试
SSH authentication: OK;
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。