天天看點

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

繼續閱讀