모니터링

2022.02.14 14:02

서버모니터링 & 네트워크모니터링 nagios 서버 설치

  • 비아웹 오래 전 2022.02.14 14:02 인기
  • 3,957
    0

오늘은 서버모니터링과 네트워크모니터링을 할수 있는 nagios를 설치해 보려고 합니다.

** 테스트 환경 : CentOS6.10

** Nagios Core 소스 설치

centos 6버전에 경우 yum 저장소가 20년 11/30일부로 만료 되었기때문에 Centos-Base.repo파일에서

직접 저장소를 지정해줘야 yum을 쓰실수 있습니다.

root@localhost:~]# vi /etc/yum.repos.d/CentOS-Base.repo
[base] name=CentOS-$releasever - Base #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra baseurl=http://vault.centos.org/6.10/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra baseurl=http://vault.centos.org/6.10/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra baseurl=http://vault.centos.org/6.10/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra baseurl=http://vault.centos.org/6.10/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra baseurl=http://vault.centos.org/6.10/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

이런식으로 지정해 주시면 편하디 편한 yum을 사용할 수 있습니다.

# yum -y install httpd

서버모니터링 nagios 의 경우 웹을 통해서 모니터링을 제공해주고 있기 때문에

기본적으로 httpd를 설치 해줍니다.

root@localhost:~]# vi /etc/selinux/config

selinux=disabled

- 필수 패키지 설치

root@localhost:~]# 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

- 계정 생성

root@localhost:~]# useradd nagios root@localhost:~]# 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

- httpd 설정 파일 변경

# vi /etc/httpd/conf/httpd.conf

158번째 줄 주석해제

LoadModule cgi_module modules/mod_cgi.so

424번째 줄 주석해제

AddHandler cgi-script .cgi

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

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

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

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

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

nagios 아파치 설정 경로 파일 : /etc/httpd/conf.d/nagios.conf

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

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

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

- 서버모니터링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

- 서버모니터링 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

감사합니다.

서버호스팅 비아웹


  • 공유링크 복사

    댓글목록

    등록된 댓글이 없습니다.