2014-11-26 3 views
2

나는 스크립트 (check_gearman.sh)를 사용하고 있기 때문에 기어공을 모니터링하려고합니다.nagios의 기어 감속 장치

로컬 호스트는 기어맨 서버가 실행되는 곳입니다.

나는

./check_gearman.sh -H localhost -p 4730 -t 1000 

그것은 결과 실행하면 :

CRITICAL : Gearman을 : gearman_client_run_tasks : gearman_wait (GEARMAN_TIMEOUT) 제한 시간은 1 개 서버가 여론 조사 (했다 도달), 어떤 서버를 사용할 수 없었다, 파이프 : 거짓 -> libgearman/universal.cc : 331 : pid (613)

어떤 사람이 나를 도와주세요.

아래 사전에 스크립트

#!/bin/sh 
# 
# gearman check for nagios 
# written by Georg Thoma ([email protected]) 
# Last modified: 07-04-2014 
# 
# Description: 
# 
# 
# 

PROGNAME=`/usr/bin/basename $0` 
PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 
REVISION="0.04" 
export TIMEFORMAT="%R" 

. $PROGPATH/utils.sh 

# Defaults 
hostname=localhost 
port=4730 
timeout=50 

# search for gearmanstuff 
GEARMAN_BIN=`which gearman 2>&1 | grep -v "no gearman in"` 
if [ "x$GEARMAN_BIN" == "x" ] ; then # result of check is empty 
    echo "gearman executable not found in path" 
    exit $STATE_UNKNOWN 
fi 
GEARADMIN_BIN=`which gearadmin 2>&1 | grep -v "no gearadmin in"` 
if [ "x$GEARADMIN_BIN" == "x" ] ; then # result of check is empty 
    echo "gearadmin executable not found in path" 
    exit $STATE_UNKNOWN 
fi 


print_usage() { 
    echo "Usage: $PROGNAME [-H hostname -p port -t timeout]" 
    echo "Usage: $PROGNAME --help" 
    echo "Usage: $PROGNAME --version" 
} 

print_help() { 
    print_revision $PROGNAME $REVISION 
    echo "" 
    print_usage 
    echo "" 
    echo "gearman check plugin for nagios" 
    echo "" 
    support 
} 

# Make sure the correct number of command line 
# arguments have been supplied 

if [ $# -lt 1 ]; then 
    print_usage 
    exit $STATE_UNKNOWN 
fi 

# Grab the command line arguments 

exitstatus=$STATE_WARNING #default 
while test -n "$1"; do 
    case "$1" in 
     --help) 
      print_help 
      exit $STATE_OK 
      ;; 
     -h) 
      print_help 
      exit $STATE_OK 
      ;; 
     --version) 
      print_revision $PROGNAME $REVISION 
      exit $STATE_OK 
      ;; 
     -V) 
      print_revision $PROGNAME $REVISION 
      exit $STATE_OK 
      ;; 
     -H) 
      hostname=$2 
      shift 
      ;; 
     --hostname) 
      hostname=$2 
      shift 
      ;; 
     -t) 
      timeout=$2 
      shift 
      ;; 
     --timeout) 
      timeout=$2 
      shift 
      ;; 
     -p) 
      port=$2 
      shift 
      ;; 
     --port) 
      port=$2 
      shift 
      ;; 
     *) 
      echo "Unknown argument: $1" 
      print_usage 
      exit $STATE_UNKNOWN 
      ;; 
    esac 
    shift 
done 

# check if server is running and replys to version query 
VERSION_RESULT=`$GEARADMIN_BIN -h $hostname -p $port --server-version 2>&1 ` 
if [ "x$VERSION_RESULT" == "x" ] ; then # result of check is empty 
     echo "CRITICAL: Server is not running/responding" 
     exitstatus=$STATE_CRITICAL 
     exit $exitstatus 
fi 

# drop funtion echo to remove functions without workers 
DROP_RESULT=`$GEARADMIN_BIN -h $hostname -p $port --drop-function echo_for_nagios 2>&1 ` 

# check for worker echo_for_nagios and start a new one if needed 
CHECKWORKER_RESULT=`$GEARADMIN_BIN -h $hostname -p $port --status | grep echo_for_nagios` 
if [ "x$CHECKWORKER_RESULT" == "x" ] ; then # result of check is empty 
    nohup $GEARMAN_BIN -h $hostname -p $port -w -f echo_for_nagios -- echo echo >/dev/null 2>&1 & 
fi 

# check the time to get the status from gearmanserver 
CHECKWORKER_TIME=$({ time $GEARADMIN_BIN -h $hostname --status ; } 2>&1 |tail -1) 

# check if worker returns "echo" 
CHECK_RESULT=`cat /dev/null | $GEARMAN_BIN -h $hostname -p $port -t $timeout -f echo_for_nagios 2>&1` 

# validate result and set message and exitstatus 
if [ "$CHECK_RESULT" = "echo" ] ; then # we got echo back 
     echo "OK: got an echo back from gearman server version: $VERSION_RESULT, responded in $CHECKWORKER_TIME sec|time=$CHECKWORKER_TIME;;;" 
     exitstatus=$STATE_OK 
    else # timeout reached, no echo 
     echo "CRITICAL: $CHECK_RESULT" 
     exitstatus=$STATE_CRITICAL 
fi 
exit $exitstatus 

감사합니다.

답변

2

mod_gearman 패키지를 다운로드하면이 패키지에는 Nagios 용 훨씬 더 많은 기능을 갖춘 check_gearman 플러그인이 포함되어 있습니다.

현재 플러그인에서 오류 메시지는 점검 스크립트가 gearman 데몬에 연결할 수 없음을 표시합니다.

포트 4370이 localhost에서 수신 대기 중인지, 로컬 방화벽 차단 연결이 없는지 확인해야합니다. gearmand를 다른 포트에 설치했거나 localhost가 아닌 네트워크 인터페이스에서만 수신 대기 할 가능성이 있습니다. 아니면 전혀 작동하지 않거나 수표를 실행하는 서버와 다른 서버에있을 수 있습니다.