天天看點

zabbix service and client deployment

what is zabbix?

英語實在太爛,沒辦法繼續了,但總有一天要將其變爲第一語言

先來看看官方給出的定義,純官方摘過來的https://www.zabbix.com/documentation/2.2/manual/introduction/about

What is Zabbix

Overview

Zabbix was created by Alexei Vladishev, and currently is actively developed and supported by Zabbix SIA.

Zabbix is an enterprise-class open source distributed monitoring solution.

Zabbix is software that monitors numerous parameters of a network and

the health and integrity of servers. Zabbix uses a flexible notification

mechanism that allows users to configure e-mail based alerts for

virtually any event. This allows a fast reaction to server problems.

Zabbix offers excellent reporting and data visualisation features based

on the stored data. This makes Zabbix ideal for capacity planning.

Zabbix supports both polling and trapping. All Zabbix reports and

statistics, as well as configuration parameters, are accessed through a

web-based frontend. A web-based frontend ensures that the status of your

network and the health of your servers can be assessed from any

location. Properly configured, Zabbix can play an important role in

monitoring IT infrastructure. This is equally true for small

organisations with a few servers and for large companies with a

multitude of servers.

Zabbix is free of cost. Zabbix is written and distributed under theGPLGeneral Public License version 2. It means that its source code is freely distributed and available for the general public.

Commercial support is available and provided by Zabbix Company.

Learn more about Zabbix features.

Users of Zabbix

Many organisations of different size around the world rely on Zabbix as a primary monitoring platform.

約定:

    系統:centos 6

    軟體版本:zabbix 2.2

    安裝目錄:/usr/local/zabbix

說明:

    軟體需求:web(apache、nginx)、php、mysql,具體不在此做說明

    此文檔采用源碼編譯安裝

    還為做深入研究,這裡隻記錄Server端和Clinet端的安裝

正文:

    下載下傳軟體:http://www.zabbix.com/download.php

一.服務端

 1.建立使用者

# groupadd zabbix
# useradd -g zabbix zabbix      

2.建立資料庫https://www.zabbix.com/documentation/2.2/manual/appendix/install/db_scripts

# cd /usr/local/src
# tar -xzvf zabbix-2.2.2.tar.gz
# cd zabbix-2.2.2      

MySQL (we assume that user username with password password exists and has permissions to create database objects):

shell> mysql -u<username> -p<password>
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> quit;
shell> mysql -u<username> -p<password> zabbix < database/mysql/schema.sql
# stop here if you are creating database for Zabbix proxy
shell> mysql -u<username> -p<password> zabbix < database/mysql/p_w_picpaths.sql
shell> mysql -u<username> -p<password> zabbix < database/mysql/data.sql      

PostgreSQL (we assume that user username exists and has permissions to create database objects):

shell> psql -U <username>
psql> create database zabbix; 
psql> \q 
shell> cd database/postgresql
shell> psql -U <username> zabbix < schema.sql
# stop here if you are creating database for Zabbix proxy
shell> psql -U <username> zabbix < p_w_picpaths.sql
shell> psql -U <username> zabbix < data.sql      

Oracle (we assume that user zabbix with password password exists and has permissions to create database objects  in service ORCL):

If you are creating database for Zabbix server you need to have p_w_picpaths somewhere on Oracle host:

# copy directory create/p_w_picpaths/old_p_w_picpaths somewhere on Oracle server (e.g. /home/oracle):
shell> scp -r create/p_w_picpaths/old_p_w_picpaths user@host:/home/oracle
# edit file database/oracle/p_w_picpaths.sql and set p_w_picpaths_dir variable to 
where you have copied them (e. g. "/home/oracle/old_p_w_picpaths"):
CREATE OR REPLACE DIRECTORY p_w_picpath_dir AS '/home/oracle/old_p_w_picpaths'      

Now prepare the database:

shell> sqlplus zabbix/password@host/ORCL
sqlplus> @database/oracle/schema.sql
# stop here if you are creating database for Zabbix proxy
sqlplus> @database/oracle/p_w_picpaths.sql
sqlplus> @database/oracle/data.sql      

3.配置幫助資訊

#./configure --help      

4.服務端安裝-mysql db

# ./configure --prefix=/usr/local/zabbix/ --enable-server \
--enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2

# make && make install      

5.服務端安裝-PostgreSQL

#./configure --enable-server --with-postgresql --with-net-snmp      

6.服務端配置

編輯/usr/local/zabbix/etc/zabbix_server.conf配置以下參數

LogFile=/tmp/zabbix_server.log    #日志檔案
DBName=zabbix                              #資料庫名稱
DBUser=zabbix                                 #資料庫使用者名
DBPassword=zabbix                        #資料庫密碼
DBPort=3306                                    #資料庫端口      

7.系統服務配置

經過上面配置,就可以通過$/usr/local/zabbix/sbin/zabbix_server啟動服務,但這種啟動方式并沒有将zabbix服務加入系統服務,那就來配置吧。

服務腳本統一在源碼目錄misc/init.d下,這裡又按系統做了區分,centos、redhat同屬fedora,是以這裡就要fedora的腳本做修改

cp misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server      

編輯/etc/init.d/zabbix_server,修改以下參數

vim  /etc/init.d/zabbix_server

BASEDIR=/usr/local/zabbix/         #zabbix安裝目錄      

加入系統服務

chkconfig --add zabbix_agentd
chkconfig --level 345 zabbix_agentd on      

啟動zabbix服務

$service zabbix_server start      

這裡還有個問題,就是SElinux的安全驗證,可使用setenfroce 0暫時關閉selinux臨時解決下

二.服務端web配置

拷貝檔案到web目錄site下http://httpd.apache.org/docs/2.2/vhosts/

cp -rp /usr/local/zabbix-2.2.2/frontends/php /site/zabbix/      

apache配置

<Directory "/site/zabbix">
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>

<VirtualHost *:80>
    #ServerAdmin 
    DocumentRoot /site/zabbix
    ServerName localhost
    ErrorLog logs/dummy-zabbix.com-error_log
    CustomLog logs/dummy-zabbix.com-access_log common
</VirtualHost>      

nginx配置

server {
    listen    80;
    server_name localhost;
    access_log zabbix.com.access.log main;
    index index.html index.php index.html;
    root  /site/zabbix;

    location /
    {
        try_files $uri $uri/ /index.php?$args;
    }
    location ~ ^(.+.php)(.*)$ {
        fastcgi_split_path_info ^(.+.php)(.*)$;
        include fastcgi.conf;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param PATH_INFO
        $fastcgi_path_info;
    }
}      

安裝前端

1.浏覽器打開http://localhost/zabbix

如果前面的配置正确,會看到安裝向導

zabbix service and client deployment

2.确認先決條件是否滿足

zabbix service and client deployment
Pre-requisite Minimum value Description
PHP version   5.3.0
PHP memory_limit option   128MB

In php.ini:

memory_limit = 128M

PHP post_max_size option   16MB post_max_size = 16M
PHP upload_max_filesize option   2MB upload_max_filesize = 2M
PHP max_execution_time option   300 seconds max_execution_time = 300
PHP max_input_time option   max_input_time = 300
PHP session.auto_start option   must be disabled session.auto_start = 0.
Database support   One of: IBM DB2, MySQL, Oracle, PostgreSQL, SQLite

One of the following modules must be installed:

ibm_db2, mysql, oci8, pgsql, sqlite3

bcmath   php-bcmath
mbstring   php-mbstring
sockets   php-net-socket. Required for user script support.
gd   2.0 or higher php-gd. PHP GD extension must support PNG p_w_picpaths (--with-png-dir), JPEG (--with-jpeg-dir) p_w_picpaths and FreeType 2 (--with-freetype-dir).
libxml   2.6.15 php-xml or php5-dom
xmlwriter   php-xmlwriter
xmlreader   php-xmlreader
ctype   php-ctype
session   php-session
gettext  

php-gettext

Starting with Zabbix 2.2.1, the PHP gettext extension

is no longer a mandatory requirement for installing Zabbix. If gettext

is not installed, the frontend will work as usual, however, the

translations will not be available.

3.配置連結資料庫資訊,前提zabbix資料庫必須已建立

zabbix service and client deployment

4.主機資訊配置

zabbix service and client deployment

5.檢查配置資訊是否正确

zabbix service and client deployment

6.生成配置檔案,這裡可能會出權限問題,可将配置檔案下載下傳後上傳到伺服器,或修改目錄權限

zabbix service and client deployment

7.登入

預設使用者為admin,密碼為zabbix

zabbix service and client deployment

8.中文支援及字型更改

zabbix本身已內建中文,但需要手動開啟後才會出現在語言設定中

編輯/site/zabbix/include/locales.inc.php檔案,找到zh_CN,将後面的falsh改為true,就可在頁面的語言設定中找到中文選項了

zabbix service and client deployment

支援中文後,在圖表資料中可能會出現亂碼情況,與字型庫有關,将windows下的C:\Windows\Fonts\simkai.ttf(楷體)上傳到伺服器 zabbix 網站目錄 fonts 目錄下

修改web目錄/site/zabbix/include/defines.inc.php檔案,做如下變更

sed -i 's/DejaVuSans/simkai/g' ./include/defines.inc.php      
43行
define('ZBX_GRAPH_FONT_NAME',        'DejaVuSans'); // font file name    修改前
define('ZBX_GRAPH_FONT_NAME',        'simkai'); // font file name       修改後
90行
define('ZBX_FONT_NAME', 'DejaVuSans');                                                修改前
define('ZBX_FONT_NAME', 'simkai');                                                         修改後      

三.用戶端

1.用戶端安裝

# groupadd zabbix
# useradd -g zabbix zabbix      
#./configure --enable-agent --prefix=/usr/local/zabbix/
make && make install      

2.用戶端配置

編輯/usr/local/zabbix/etc/zabbix_agentd.conf配置以下參數

LogFile=/tmp/zabbix_agentd.log        #日志配置
Server=127.0.0.1                                   #zabbix服務端位址,允許服務端主動來取資料
ServerActive=127.0.0.1                        #zabbix服務端位址,主動向服務端送出資料
Hostname=Zabbix server                    #用戶端名稱,這個名稱後面在服務端添加監控主機時要用到      

3.加入系統自啟動服務

cp misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_agentd      

編輯/etc/init.d/zabbix_agentd,修改以下參數

vim  /etc/init.d/zabbix_agentd

BASEDIR=/usr/local/zabbix/         #zabbix安裝目錄      
chkconfig --add zabbix_agentd
chkconfig --level 345 zabbix_agentd on      

啟動用戶端

service zabbix_agentd start