nagios错误的Bash脚本:stdout上没有输出 - 在命令行上正常工作

时间:2017-11-14 22:22:31

标签: bash sed nagios

晚上好人,

我试图从几个远程服务器上读取内部构建软件的构建版本并在Nagios上显示

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

  

"(stdout没有输出)stderr:execvp(/ usr / local / nagios / libexec / chk_prg_version,...)失败。 errno是2:没有这样的文件或目录"

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

#!/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

1 个答案:

答案 0 :(得分:0)

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