2017-11-14 23 views
0

좋은 저녁 사람들에 잘 작동 Nagios는배쉬 스크립트를 표준 출력에 출력이 - 나는 여러 원격 서버에서 자체 내장 된 소프트웨어의 빌드 버전을 읽고 표시하기 위해 노력하고있어</p> <p>, 명령 줄

에 스크립트는 명령 행에서 완벽하게 실행 만의 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 [email protected]://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 
+2

스크립트 chk_prg_version이/usr/local/nagios/libexec 디렉토리에 저장되어 있습니까? – gile

+0

파이프 라인'sshpass -f "password"scp -r user @ serverName : // FileLocation/FileName/tmp/storenumber'가 실패하면 어떻게됩니까? – AlexP

+0

@gile 예,/usr/local/nagios/libexec에 있습니다. 그렇지 않으면 nagios 서비스를 다시 시작할 수 없으며 오류 메시지가 표시됩니다. –

답변

0

답변을 알아낼 수있었습니다 : 명령에 플러그인을 읽는 오타가있었습니다. 이제는 아주 잘 작동합니다.