모니터링 - Zabbix

서버는 CentOS 6.5 에서 RPM 패키지를 이용하여 설치하는 것을 기준으로 설명합니다.

설치에 대한 정보는 기본적으로 Zabbix 공식문서를 참조로 합니다.

https://www.zabbix.com/documentation/2.2/manual/installation/install_from_packages

본격적으로 도입하기에 앞서, 모든 기록은 Zabbix server의 서버시간을 기준으로 기록되므로, 서버는 표준시에 동기화 되어있는것을 권장합니다.

서버 설치

패키지 설치

설치를 위한 공식 레파지토리 등록

rpm -Uvh http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm

설치 (2014/1/28 기준으로 2.2.1-1)

yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-web
yum -y install zabbix-agent zabbix-get

패키지 설치 완료후 레파치토리 비활성화

enabled=1 을 enabled=0 으로 변경

vi /etc/yum.repos.d/zabbix.repo

---------------------------------------------------------------

[zabbix]

name=Zabbix Official Repository - $basearch

baseurl=http://repo.zabbix.com/zabbix/2.2/rhel/6/$basearch/

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX

[zabbix-non-supported]

name=Zabbix Official Repository non-supported - $basearch

baseurl=http://repo.zabbix.com/non-supported/rhel/6/$basearch/

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX

gpgcheck=1

---------------------------------------------------------------

DB 설치

MySQL를 설치하고 Zabbix용 DB와 사용자를 작성

MySQL 설치 (CentOS 기본 버전인 5.1.x 설치하여 사용하기로 한다.)

yum install mysql-server
/etc/init.d/mysqld start
/usr/bin/mysql_secure_installation
mysql -u root -p

-(아래 실행)------------------------------------

Zabbix용 DB의 작성

create database zabbix character set utf8;

Zabbix용 사용자 작성

grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix-password';

설정의 반영

FLUSH PRIVILEGES;

exit

------------------------------

Zabbix용 DB스키마와 데이터를 임포트

mysql -uroot -p zabbix < /usr/share/doc/zabbix-server-mysql-2.2.1/create/schema.sql
mysql -uroot -p zabbix < /usr/share/doc/zabbix-server-mysql-2.2.1/create/images.sql
mysql -uroot -p zabbix < /usr/share/doc/zabbix-server-mysql-2.2.1/create/data.sql

zabbix서버의 설정

vi /etc/zabbix/zabbix_server.conf

---(아래를 변경)------------------------------------

DBPassword=

DBPassword=zabbix-password

------------------------------

WEB 설정

서버 부팅시 Zabbix서버의 자동 시작을 설정

chkconfig zabbix-server on

PHP 설정에서 Timezone 설정

vi /etc/php.ini

;date.timezone =

date.timezone = Asia/Seoul

Zabbix WEB UI를 사용하기 위해 Apache를 다시 실행

service httpd restart

----------------------------------------------

[root@localhost ~]# cat /etc/httpd/conf.d/zabbix.conf

#

Zabbix monitoring system php web frontend

#

Alias /zabbix /usr/share/zabbix

<Directory "/usr/share/zabbix">

Options FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

php_value max_execution_time 300

php_value memory_limit 128M

php_value post_max_size 16M

php_value upload_max_filesize 2M

php_value max_input_time 300

  1. php_value date.timezone Europe/Riga

</Directory>

<Directory "/usr/share/zabbix/conf">

Order deny,allow

Deny from all

<files *.php>

Order deny,allow

Deny from all

</files>

</Directory>

<Directory "/usr/share/zabbix/api">

Order deny,allow

Deny from all

<files *.php>

Order deny,allow

Deny from all

</files>

</Directory>

<Directory "/usr/share/zabbix/include">

Order deny,allow

Deny from all

<files *.php>

Order deny,allow

Deny from all

</files>

</Directory>

<Directory "/usr/share/zabbix/include/classes">

Order deny,allow

Deny from all

<files *.php>

Order deny,allow

Deny from all

</files>

</Directory>

초기 설정

아래와 같은 주소로 웹브라우져에서 접속하여 초기 설정을 합니다.

http://서버주소/zabbix/

------------------------------

우선 admin 계정의 암호를 변경합니다.

Agent 설치(모니터링 대상 서버)

설정

Configuration → Hosts → Create Host

Monitoring → Latest Data

CentOS 5/6

yum install zabbix-agent

/etc/init.d/zabbix-agent start

chkconfig zabbix-agent on

[root@localhost ~]# egrep -v "^#|^$" /etc/zabbix/zabbix_agentd.conf

PidFile=/var/run/zabbix/zabbix_agentd.pid

LogFile=/var/log/zabbix/zabbix_agentd.log

LogFileSize=0

Server=127.0.0.1

ServerActive=127.0.0.1

Hostname=Zabbix server

Include=/etc/zabbix/zabbix_agentd.d/

[root@localhost ~]# ps aux | grep zabbix_agent

zabbix 2775 0.0 0.1 76844 1340 ? S 00:10 0:00 /usr/sbin/zabbix_agentd

zabbix 2776 0.0 0.1 76844 1276 ? S 00:10 0:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]

zabbix 2777 0.0 0.1 76844 1500 ? S 00:10 0:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]

zabbix 2778 0.0 0.1 76844 1432 ? S 00:10 0:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]

zabbix 2779 0.0 0.1 76844 1500 ? S 00:10 0:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]

zabbix 2780 0.0 0.1 76844 1280 ? S 00:10 0:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

root 2888 0.0 0.0 103244 852 pts/0 S+ 00:13 0:00 grep zabbix_agent

[root@localhost ~]# cat /var/log/zabbix/zabbix_agentd.log

2775:20140128:001050.151 Starting Zabbix Agent [Zabbix server]. Zabbix 2.2.1 (revision 40808).

2775:20140128:001050.152 using configuration file: /etc/zabbix/zabbix_agentd.conf

2778:20140128:001050.154 agent #2 started [listener #2]

2777:20140128:001050.155 agent #1 started [listener #1]

2779:20140128:001050.155 agent #3 started [listener #3]

2776:20140128:001050.155 agent #0 started [collector]

2780:20140128:001050.156 agent #4 started [active checks #1]

Debian 5/6/7

Ubuntu 10.04

configure에서 no acceptable C compiler found in $PATH 오류
http://junemoon.tistory.com/30
gcc를 설치하면 된다.

wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.1/zabbix-2.2.1.tar.gz

tar xvfz zabbix-2.2.1.tar.gz

cd zabbix-2.2.1

./configure --prefix=/usr/local/zabbix --enable-agent

make install

groupadd zabbix

useradd -g zabbix zabbix -s /bin/false

/usr/local/zabbix/sbin/zabbix_agentd -c /usr/local/zabbix/etc/zabbix_agentd.conf

Windows XP/7