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
如果前面的配置正确,会看到安装向导
2.确认先决条件是否满足
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 | In php.ini: post_max_size = 16M |
PHP upload_max_filesize option | 2MB | In php.ini: upload_max_filesize = 2M |
PHP max_execution_time option | 300 seconds | In php.ini: max_execution_time = 300 |
PHP max_input_time option | 300 seconds | In php.ini: max_input_time = 300 |
PHP session.auto_start option | must be disabled | In php.ini: 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数据库必须已创建
4.主机信息配置
5.检查配置信息是否正确
6.生成配置文件,这里可能会出权限问题,可将配置文件下载后上传到服务器,或修改目录权限
7.登录
默认用户为admin,密码为zabbix
8.中文支持及字体更改
zabbix本身已集成中文,但需要手动开启后才会出现在语言设置中
编辑/site/zabbix/include/locales.inc.php文件,找到zh_CN,将后面的falsh改为true,就可在页面的语言设置中找到中文选项了
支持中文后,在图表数据中可能会出现乱码情况,与字体库有关,将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
如何创建监控主机,待研究明白了在来补