nagios 실행 명령어는 bin/nagios  이다.

그런데, 이 bin/nagios 실행후 이게 데몬으로 실행되어야 잘 동작한다. 이 부분을 잘 쓸 수 있도록 script를 생성했다. 


bin/nagios 명령어의 파라미터 옵션은 다음과 같다. 


Options:


  -v, --verify-config          Verify all configuration data

  -s, --test-scheduling        Shows projected/recommended check scheduling and other

                               diagnostic info based on the current configuration files.

  -x, --dont-verify-paths      Don't check for circular object paths - USE WITH CAUTION!

  -p, --precache-objects       Precache object configuration - use with -v or -s options

  -u, --use-precached-objects  Use precached object config file

  -d, --daemon                 Starts Nagios in daemon mode, instead of as a foreground process







check-nagios-config.sh


#!/bin/bash


CUR_PWD=`pwd`

NAGIOS_HOME=/app/tomcat/nagios/nagios

cd $NAGIOS_HOME

bin/nagios -v etc/nagios.cfg

cd $CUR_PWD






restart-nagios.sh


#!/bin/bash



# start bin/nagios

CUR_PWD=`pwd`

NAGIOS_HOME=/app/nagios

cd $NAGIOS_HOME


# syntax check(verification), precache object creation

bin/nagios -v -p -s etc/nagios.cfg


if [[ $? > 0 ]]; then 

    echo 'there are some error. check configs'

    exit $?;

else 

    PID=`ps -ef | grep bin/nagios | grep -v grep | awk '{print $2}'`

    if [ -n "$PID" ]; then 

        kill -9 $PID;

        echo "bin/nagios killed."

    fi

    # precache object use

     bin/nagios -u -d etc/nagios.cfg

     echo 'start nagios...'

fi




Posted by '김용환'
,