比较来自世界各地的卖家的域名和 IT 服务价格

NRPE: 用户脚本无法读取输入,但脚本正常工作,它可以是什么?

我写了一个脚本检查 Nagios, 这使其作为参数和检查方式:

如果设置了路径

如果可用,请触摸途中的文件。

如果挂载点目录是空的

[root@hadoop-nn1 mass1]# su - nagios
[nagios@hadoop-nn1 ~]$ /usr/lib64/nagios/plugins/check_nfsmount.sh /mass2/hpfiles/
Warning: /mass2/hpfiles/ is mounted but directory is empty!
[nagios@hadoop-nn1 ~]$ /usr/lib64/nagios/plugins/check_nfsmount.sh /mass1/hpfiles/
Warning: /mass1/hpfiles/ is MOUNTED properly but not writeable for user nagios
[nagios@hadoop-nn1 ~]$ /usr/lib64/nagios/plugins/check_nfsmount.sh /mass1/hp_offline/
Ok: /mass1/hp_offline/ is MOUNTED properly and writeable for user nagios
[nagios@hadoop-nn1 ~]$

B.

/etc/nagios/nrpe.cfg

看起来像:

command[check_nfsmounts]=/usr/lib64/nagios/plugins/check_nfsmounts.sh $ARG1$

正如您可以看到的,当使用用户从跟踪计算机启动命令时 Nagios 结果是预期的,但是当我使用团队使用时

nrpe

使用服务器 Nagios 他回来了 «NRPE: Unable to read input».

我尝试过的其他事情:

在脚本本身提供路径,因此无需通过 NRPE, 但同样的结果。

确保内部的路径

nrpe.cfg

, 还要避免转移参数,但无济于事。

我编辑了

nrpe.cfg

然后打开调试,然后在操作期间

tail -f /var/log/messages |grep nrpe

并从服务器发送远程命令 Nagios, 我在期刊中看到这两条线:

Dec 15 04:09:44 hadoop-nn1 nrpe[9354]: Error: Request contained illegal metachars!
Dec 15 04:09:44 hadoop-nn1 nrpe[9354]: Client request was invalid, bailing out...

但我没有机会知道它是什么违法的象征 ...

对于参数 Don't_blame_nrpe 安装值 1. 脚本如下所示:

#!/bin/bash
# This script checks if the provided mount point is mounted and writeable.
# Script by Itai Ganot
if [ -z "$1" ]; then
echo "Usage: $(basename $0) PATH_TO_CHECK"
echo "Available PATH's: /mass1/hp_offline -- /mass1/hpfiles -- /mass2/hpfiles"
exit 3
fi
DF="/bin/df -t nfs"
GREP="/bin/grep -q"
AWK="/bin/awk"
TOUCH="/bin/touch"
LS="/bin/ls"
WC="/usr/bin/wc"
TESTFILE="test.dat"
USER=$(whoami)
NFS_MOUNT="$1"
$DF | $GREP "$NFS_MOUNT" | $AWK '{print $5}'
if [ $? = 0 ]; then
MOUNTED="yes"
else
MOUNTED="no"
fi
if [[ "$MOUNTED" = "yes" ]] && [[ $($LS -A "$NFS_MOUNT" | "$WC" -l) -gt "1" ]]; then
"$TOUCH" "$NFS_MOUNT""$TESTFILE" 2>/dev/null
if [ $? = 0 ]; then
TOUCHED="yes"
else
TOUCHED="no"
fi
elif [[ "$MOUNTED" = "yes" ]] && [[ $($LS -A "$NFS_MOUNT" | "$WC" -l) -eq "0" ]]; then
TXT="$NFS_MOUNT is mounted but directory is empty!"
RETVAL="1"
STATUS="Warning"
elif [ "$MOUNTED" = "no" ]; then
TXT="$NFS_MOUNT not MOUNTED"
RETVAL="2"
STATUS="Critical"
fi

if [[ "$TOUCHED" = "yes" ]]; then
TXT="$NFS_MOUNT is MOUNTED properly and writeable for user $USER"
RETVAL="0"
STATUS="Ok"
elif [[ "$TOUCHED" = "no" ]] || [[ "$MOUNTED" = "no" ]]; then
TXT="$NFS_MOUNT is MOUNTED properly but not writeable for user $USER"
RETVAL="1"
STATUS="Warning"
fi
echo "$STATUS: $TXT"
exit $RETVAL

什么可能是出现错误的原因 «NRPE: 无法读取输入“?

编辑 # 1:

[root@mon1 ~]# /usr/lib64/nagios/plugins/check_nrpe -H 10.39.21.211 -c check_nfsmounts -a /mass1/hp_offline
NRPE: Unable to read output
[root@mon1 ~]# /usr/lib64/nagios/plugins/check_nrpe -H 10.39.21.211 -c check_nfsmounts -a '/mass1/hp_offline'
NRPE: Unable to read output
[root@mon1 ~]# /usr/lib64/nagios/plugins/check_nrpe -H 10.39.21.211 -c check_nfsmounts /mass1/hp_offline
NRPE: Unable to read output
[root@mon1 ~]#

编辑 # 2: SSL 在服务器上禁用 Nagios, 和所有客户 ...

[root@mon1 ~]# /usr/lib64/nagios/plugins/check_nrpe -H 10.39.21.211 -n -c check_nfsmounts '/mass1/hp_offline'
CHECK_NRPE: Error receiving data from daemon.
[root@mon1 ~]# /usr/lib64/nagios/plugins/check_nrpe -H 10.39.21.211 -n -c check_nfsmounts -a '/mass1/hp_offline'
CHECK_NRPE: Error receiving data from daemon.

先感谢您
已邀请:

小姐请别说爱

赞同来自:

你贯穿的命令 nrpe, 看起来像:

/usr/lib64/nagios/plugins/check_nfsmounts.sh

, 但是你从命令行测试的那个,

/usr/lib64/nagios/plugins/check_nfsmount.sh

. 您确认这种不一致是问题的根源 - 而且别担心,它可能发生在我们任何人身上。 第二眼对始终有用,可捕捉这些非常讨厌的小格雷利夫!

要回复问题请先登录注册