Bash script for nagios error: No output on stdout - works fine on command line

Bash script for nagios error: No output on stdout - works fine on command line

大家晚上好,

我正在尝试从多个远程服务器读取内部构建软件的构建版本并将其显示在 Nagios 上

该脚本在命令行上运行完美,但在 Nagios 上我收到此错误消息:

"(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/chk_prg_version, ...) failed. errno is 2: No such file or directory"

这是我的脚本(没有原始数据,敏感不用说)

#!/bin/bash

#copy the file to local temp and rename it for uniqueness
sshpass -f "password" scp -r user@serverName://FileLocation/FileName /tmp/storenumber

#Scan the file and grep anything after the string Program-Version:
pversion=$(grep "Program-Version:" /tmp/MFileName | sed 's/^.*: //')

#nagios checks
if [ if the pversion matches the latest release version ]
then
    echo "OK - $pversion"
    exit 0
elif [ if the pversion is any of the previous releases ]
then
    echo "warning error message"
    exit 1
elif [ if returns a value that doesn't match any release ]
then
    echo "critical error message"
    exit 2
else
    echo "uknown"
    exit 3
fi

#delete the file
rm /tmp/storenumber

我找到了答案:该命令有一个读取插件的拼写错误。它现在工作得非常好。