YUMSERV
article thumbnail
Published 2020. 5. 5. 21:46
Nagios 서버 구성 MONITORING
반응형

이번 주제로는 Nagios 서버를 구축해보고, 모니터링을 하는 방식, 마지막으로 텔레그램을 연동하는 방법까지 총 3가지 파트로 나누어서 얘기해보고자 합니다.

 

1. Nagios란 무엇인가?

 

Nagios는 오픈소스 모니터링 프로그램으로 
전체 IT인프라를 모니터링하여 웹, 응용프로그램 등 해당 프로세스가 정상적으로 작동하는지 확인합니다.

또한 시스템 뿐만 아니라, 네트워크 장치에 대한 모니터링도 가능하며, 알림 기능 또한 제공하고 있습니다.

Nagios 종류로는  오픈소스 버전인 Nagios Core와 상용버전인 Nagios XI 두가지가 있습니다.

Nagios에서 실제로 모니터링을 담당하는 시스템을 Nagios 서버라고 하며, 모니터링이 되는 대상 시스템을 Nagios 에이전트 또는 타켓이라고 부릅니다. 

 

Nagios Core : 로컬 호스트를 모니터링 할 수 있으며, CPU, 메모리 사용량 등 다양하게 모니터링이 가능합니다.

Nagios Plugin : 모니터링할 수 있는 옵션들로, 이 플러그인을 사용하여 원하는 모니터링을 설정할 수 있습니다. 개인이 스크립트를 이용해서 플러그인들을 제작할 수 있습니다.

Nagios addon : nrpe, nsca등 다양한 애드온이 있습니다. nagios를 사용하는데 유용한 유틸리티입니다.

NRPE : 원격 서버 모니터링으로 원격 서버의 플러그인을 동작시켜 원격지의 상태를 확인할 수 있습니다.

 

 

2. Nagios Core 설치

 

** 테스트 환경 : CentOS7 

** Nagios Core 소스 설치

 

- 필수 패키지 설치

$ yum -y update

 

* Nagios 의 경우 웹을 통해서 모니터링을 제공해주고 있습니다. yum으로 설치하거나, 소스설치를 진행해도 되며, 필요없는경우 웹서비스를 설치를 안하셔도 됩니다.

YUM 설치시

$ yum -y install mysql mysql-server httpd php php-mysql

 

 

소스설치시 아래 글 참조하시면 됩니다.

아래 글 클릭!!

[LINUX/WEB] - CentOS8 - Apache + Mysql + PHP 소스설치

 

- selinux 해제

$ vi /etc/selinux/config
SELINUX=disabled

 

- 필수 패키지 설치

$ yum install -y gcc glibc glibc-common wget unzip gd gd-devel xinetd perl-Net-SNMP gcc glibc glibc-common make gettext automake wget openssl-devel net-snmp net-snmp-utils epel-release gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils mail sendmail perl perl-CGI

 

 

- 계정 생성

$ useradd nagios
$ usermod -a -G nagios nobody

 

- Nagios Core 설치

 

$ cd /usr/local/src
$ wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.3.4.tar.gz
$ tar xvfz nagioscore.tar.gz 
$ cd nagioscore-nagios-4.3.4/
$ ./configure
$ make all
$ make install

 

- Nagios Core 서비스 등록 

$ make install-init
$ chkconfig --add nagios
$ make install-commandmode

 

- Nagios Core 구성파일 설치

$ make install-config

 

- Apache 구성파일 설치

$ make install-webconf

 

* APM을 소스설치할 경우에는 설정해야 되는 부분

 

$ cp -arp /etc/httpd/conf.d/nagios.conf /usr/local/apache/conf/extra/

$ vi /usr/local/apache/conf/httpd.conf
# 158번째 줄 주석해제
LoadModule cgi_module modules/mod_cgi.so
# 424번째 줄 주석해제
AddHandler cgi-script .cgi
# 아래 내용 추가
# nagios settings
Include conf/extra/nagios.conf

 

 

- 웹 접속용 사용자 계정 만들기

$ htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
$ service httpd restart

 

웹에서 http://IP/nagios 로 접속해보면 패스워드를 입력하는 창이 나오게 됩니다.

방금 전 설정한 계정정보와 패스워드를 입력하게 되면

Nagios core 홈페이지가 뜨는것을 볼 수 있습니다

nagios 아파치 설정 경로 파일 : /usr/local/apache/conf/extra/nagios.conf

nagios 웹 소스파일 경로 : /usr/local/nagios/share/

 

* 에러 발생시)
apache 시작이후에 403 에러 발생했을 경우

httpd.conf 파일 내에 DirectoryIndex index.html index.php 추가했는지 확인

 

 

 

 

3. Nagios Plugin 설치

$ cd /usr/local/src
$ wget wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
$ tar xvfz nagios-plugins.tar.gz 
$ cd nagios-plugins-release-2.2.1/
$ ./tools/setup
$ ./configure
$ make && make install
$ service nagios stop
$ service nagios start

 

 

4. Nagios NRPE 설치

- 필수 패키지 설치

$ yum install mod_ssl openssl-devel gcc make openssl perl xinetd

 

- Nagios NRPE 설치

$ wget https://github.com/NagiosEnterprises/nrpe/archive/nrpe-2-15.tar.gz
$ tar xvfz nrpe-2-15.tar.gz 
$ cd nrpe-nrpe-2-15/
$ ./configure 
$ make && make install

 

- 설정파일 복사

$ cp -arp sample-config/nrpe.cfg /usr/local/nagios/etc

 

- xinetd 설정

$ make install-xinetd
$ vi /etc/services
# 아래 내용 추가
nrpe            5666/tcp                # NRPE
amqps           5671/tcp                # amqp protocol over TLS/SSL

 

- nagios와 통신할 수 있는 check_nrpe 내용 추가

$ vi /usr/local/nagios/etc/objects/commands.cfg
맨 아래 내용 추가
# 'check_nrpe' command definition
define command{
     command_name     check_nrpe
     command_line       /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
     }

 

$ service xinetd restart

 

반응형

'MONITORING' 카테고리의 다른 글

Nagios 텔래그램 연동  (1) 2020.05.11
Nagios 클라이언트 구성  (0) 2020.05.11
Zabbix 4.2 설치 및 설정  (0) 2019.06.01
Cockpit 설치 및 설정  (0) 2019.06.01
DarkStat 설치  (0) 2019.06.01
profile

YUMSERV

@lena04301

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!