VPS 시리즈 - nagios 클라이언트, 서버 설치 구성

설치 설정nagios 클라이언트와 서버
nagios 서버: 192.168.6.103
웹 서버: 192.168.6.100(nagios 클라이언트)
mysql 서버: 192.168.6.101(nagios 클라이언트)
1. Nagios 모니터링 클라이언트
1. 클라이언트에 모니터링 플러그인 설치

useradd -s /usr/sbin/nologin nagios

tar zxvf nagios-plugins-1.4.14.tar.gz

cd nagios-plugins-1.4.14

./configure

make

make install

플러그인 디렉터리 권한 설정

chown nagios.nagios /usr/local/nagios

chown -R nagios.nagios /usr/local/nagios/libexec

2. nrpe 데몬 설치

tar zxvf nrpe-2.12.tar.gz

cd nrpe-2.12

./configure

make all

make install-plugin

make install-daemon

make install-daemon-config

xinetd 서비스 nrpe 수호 프로세스로

make install-xinetd

xinetd nrpe 설정은 모니터링 서버만 모니터링

vim /etc/xinetd.d/nrpe

only_from       = 127.0.0.1 < nagios IP >

nrpe 데몬 추가

vim  /etc/services

마지막 가입

nrpe      5666/tcp       #NRPE

나중에 xinetd 서비스 다시 시작

/etc/init.d/xinetd restart

3. 서버가 일어났는지 확인

netstat -ant |grep 5666

tcp        0      0 0.0.0.0:5666            0.0.0.0:*               LISTEN

5666 포트가 이미 감청을 시작한 것을 보니 문제없다는 것을 알 수 있다
로컬 통신 가능 여부 테스트

/usr/local/nagios/libexec/check_nrpe -H localhost

NRPE v2.12

4. 서버 컨텐츠 모니터링 설정

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10

command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20

command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /

command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z

command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 250 -c 300

command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20 -c 10

2. 서버에 nrpe를 설치하고nagios 서비스를 설정합니다.
1. nrpe 설치

tar zxvf nrpe-2.12.tar.gz

cd nrpe-2.12

./configure

make all

nrpe 플러그인 설치

make install-plugin

2. 플러그인과 클라이언트가 제대로 통신하는지 테스트

/usr/local/nagios/libexec/check_nrpe -H 192.168.6.101

NRPE v2.12

3. check_ 만들기nrpe 모니터링 파일

vim /usr/local/nagios/etc/commands.cfg

define command{

command_name check_nrpe

command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

}

4. nagios를 수정한다.cfg 할당 파일 추가
저장 프로필 디렉터리 만들기

mkdir -p /usr/local/nagios/etc/monitor

프로파일 수정

vim /usr/local/nagios/etc/nagios.fg

cfg_dir=/usr/local/nagios/etc/monitor

5. 호스트 서비스 호스트 그룹 연락처 그룹 만들기

cd /usr/local/nagios/etc/monitor

a. 호스트를 만듭니다.Cfg

define host{

        use                     linux-server

        host_name               web

        alias                   edgora-web

        address                 192.168.6.100

        }

define host{

        use                     linux-server

        host_name               mysql

        alias                   edgora-mysql

        address                 192.168.6.102

        }

b. 서비스를 만듭니다.Cfg

#################  edgora   web  #####################

define service{

        use                             local-service

        host_name                       web

        service_description             PING

        check_command                   check_ping!100.0,20%!500.0,60%

        }

define service{

        use                             local-service

        host_name                       web

        service_description             SSH

        check_command                   check_ssh!8022

        }

define service{

        use                             local-service

        host_name                       web

        service_description             DISK

        check_command                   check_nrpe!check_hda1

define service{

        use                             local-service

        host_name                       web

        service_description             Load

        check_command                   check_nrpe!check_load

        }

define service{

        use                             local-service

        host_name                       web

        service_description             SWAP

        check_command                   check_nrpe!check_swap

        }

define service{

        use                             local-service

        host_name                       web

        service_description             User

        check_command                   check_nrpe!check_users

        }

define service{

        use                             local-service

        host_name                       web

        service_description             Zombie_procs

        check_command                   check_nrpe!check_zombie_procs

        }

define service{

        use                             local-service

        host_name                       web

        service_description             total_procs

        check_command                   check_nrpe!check_total_procs

        }

##################################  MYSQL  #######################

define service{

        use                             local-service

        host_name                       mysql

        service_description             PING

        check_command                   check_ping!100.0,20%!500.0,60%

        }

define service{

        use                             local-service

        host_name                       mysql

        service_description             SSH

        check_command                   check_ssh!8022

        }

define service{

        use                             local-service

        host_name                       mysql

        service_description             DISK

        check_command                   check_nrpe!check_hda1

        }

define service{

        use                             local-service

        host_name                       mysql

        service_description             Load

        check_command                   check_nrpe!check_load

        }

define service{

        use                             local-service

        host_name                       mysql

        service_description             User

        check_command                   check_nrpe!check_users

        }

define service{

        use                             local-service

        host_name                       mysql

        service_description             Zombie_procs

        check_command                   check_nrpe!check_zombie_procs

        }

define service{

        use                             local-service

        host_name                       mysql

        service_description             total_procs

        check_command                   check_nrpe!check_total_procs

        }

define service{

        use                             local-service

        host_name                       mysql

        service_description             SWAP

        check_command                   check_nrpe!check_swap

        }

c. 호스트 렌탈 파일 만들기

vim hostgroups.Cfg

define hostgroup {

      hostgroup_name  sa-servers

      alias           sa servers

      members         web,mysql

}

d. 연락처 그룹 만들기

vim contactgroup.cfg

define contactgroup {

      contactgroup_name    sagroup

      alias                system administrator group

      members              ludy

}

3. 테스트 스크립트는 문제없다

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

4. nagios 다시 시작

/etc/init.d/nagios restart

5. 웹 테스트 연결
http://192.168.6.103/nagios

좋은 웹페이지 즐겨찾기