This article reprinted from: https://www.93bok.com
A, Linux briefly popular open source monitoring system
cacti:存储数据能力强,报警性能差
nagios:报警性能差,存储数据仅有简单的一段可以判断是否在合理范围内的数据长度,储存在内存中。比如,连续采样数据存储,有连续三次不在合理范围内的数据就报警
zabbix:结合上面两种工具的优点,又可以存储数据,又可以报警。
Two, Zabbix component functionality
Server
- Zabbix server is monitoring agent reporting system availability, system integrity and complete the core components of statistical information. Zabbix Server is all the configuration information, core memory statistics and operational data.
Database storage
- All data collected Zabbix configuration information and are stored in a database.
Web Interface
- For any platform from anywhere and have easy access to Zabbix, Zabbix provides a Web-based interface. The interface is part of Zabbix Server, usually (but not necessarily) with Zabbix Server running on the same physical machine.
- If you are using SQLite, Zabbix Web interface must keep Zabbix Server running on the same physical machine.
Proxy Proxy
- Zabbix proxy can collect performance and availability data for Zabbix Server. Proxy A proxy server is optional part of Zabbix software deployment; of course, Proxy proxy server can help a single Zabbix Server to share the load pressure.
Agent monitoring agent
- Zabbix agents monitoring agent monitors deployed on the target that actively monitor local resources and applications, and the data collected is reported to Zabbix Server.
data flow
- In addition, understanding of internal Zabbix data flows equally important. To create a monitored item used to collect data, you must first create a host. Conversion to other parts of Zabbix function, you must first have a monitored item to create a trigger, you must have a trigger to create action. So, if you want to receive the X server CPU load is too high alarm, you must first create a host entity for the X server and associated with a CPU for monitoring items monitored, and if the CPU load is too high will activate the trigger and then perform an action, send you e-mail alerts.
Three, Zabbix operating mechanism
Zabbix monitoring process can be simply described as:
- Data acquisition -> data storage -> Data Analysis -> Display Data -> Alarm Monitor
Monitoring works:
- ZabbixAgent services related to data transfer from the system to get ZabbixServer, then after analyzing PHP page to show the data out ZabbixServer Service Award
- Zabbix supports a variety of monitoring the network, it can be distributed by the deployment and installation Zabbix monitoring agent, collecting data by C / S mode, B / S model and display the Web terminal configuration! Agent monitoring port 10050
Four, Zabbix Features
data collection
1、可用性和性能检查
2、支持SNMP(包括捕获和主动轮训),IPMI,JMX,VMware监控
3、自定义检查
4、按照自定义的间隔收集需要的数据
Flexible threshold defined
- Can be very flexible definition of the threshold value, called the trigger, the trigger obtain the reference value from the backend database
Highly configurable alarms of
1)可以根据升级计划,接收方和媒体类型来定制发送告警通知
2)使用宏变量可以使告警通知更有意义更高效
3)自动化动作包含执行远程命令
Real-time charting
- Use the built-in graphing functions can be monitored item contents immediately to chart
Web monitoring
- Zabbix can simulate mouse actions on the Web site to check the functionality of the Web and response time
Rich visualization options
1)能够创建自定义的图形,图形中可将多个监控项组合在一个视图展示
2)网络拓扑图
3)以仪表盘的样式展现自定义的展现和幻灯片
4)报告
5)监控资源的高级(业务)视图
Historical data storage
1)数据存储在数据库中
2)可配置历史数据
3)内置数据管理机制
Simple configuration
1)将被监控对象添加为主机
2)主机被创建用于监控,在数据库中是唯一存在的
3)应用模板来监控设备
Using Templates
1)在模板中分组检查
2)模板可以关联其他模板
Network Discovery
1)自动发现网络设备
2)监控代理自动注册
3)发现文件系统,网络接口和SNMP OID值
Simple Web interface
1)Web前端基于PHP
2)可从任何地方访问
3)你可以定制自己的操作方式
4)审核日志
Zabbix API
- Zabbix Zabbix API to provide external programmable interface for batch operations, third-party software integration and other purposes
Rights management system
1)安全用户认证
2)特定用户可以限制访问特定的视图
Powerful and easy to extend the monitoring agent
1)部署在被监控对象上
2)可以部署在Linux和Windows上
Binary code
1)为了性能和更少内存的占用,用C语言编写
2)便于移植
Prepare for the complex environment
- Zabbix proxy using a proxy server, which makes remote monitoring easier
Five, Zabbix official website to download
- Download:
https://www.zabbix.com/download
- Official Handbook:
https://www.zabbix.com/documentation/3.4/zh/manual
Six, Zabbix source compiler installation
(A) build environment LNMP
Skip the detailed process before can refer to the article "Centos7.2 LNMP source compiler environment"
(B) source compiler installed Zabbix for server terminal
1. Modify the php.ini configuration file
vim /etc/php/php.ini
date.timezone = Asia/Shanghai
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
2. Create the Zabbix database
mysql -u root -p123456
mysql> create database zabbix;
mysql> grant all on zabbix.* to zabbix@'localhost' identified by 'nongkaige';
mysql> flush privileges;
3. Test user can log database using zabbix
mysql -u zabbix -pnongkaige
4. Import Zabbix database
- Import zabbix database architecture that has been the source package, first unpack the source package zabbix
cd /a01/apps/apps_src/
tar -zxvf zabbix-3.2.11.tar.gz
- It must be introduced in order:
mysql -u zabbix -pnongkaige zabbix < /a01/apps/apps_src/zabbix-3.2.11/database/mysql/schema.sql
mysql -u zabbix -pnongkaige zabbix < /a01/apps/apps_src/zabbix-3.2.11/database/mysql/images.sql
mysql -u zabbix -pnongkaige zabbix < /a01/apps/apps_src/zabbix-3.2.11/database/mysql/data.sql
5. Installation source compiler zabbix
1) Create a zabbix run user (if you start zabbix process as root, it will automatically switch to zabbix users)
useradd -M -s /sbin/nologin zabbix
2) install dependencies
cd /a01/apps/apps_src/zabbix-3.2.11
yum -y install libevent-devel libxml2-devel libcurl-devel net-snmp-devel
3) compile zabbix
./configure --prefix=/a01/apps/zabbix --sysconfdir=/etc/zabbix --datadir=/a01/apps/zabbix/data --enable-server --enable-agent --enable-java --with-mysql --with-net-snmp --with-libcurl --with-libxml2
- Note: It is best to bring --enable-java compile-time parameters, to facilitate future monitoring program tomcat with time.
4) install java
- 报错:configure: error: Unable to find "javac" executable in path
- Not installed java environment, to install what you can
cd /a01/apps/apps_src/
mkdir -p /usr/local/java
tar -zxvf jdk-8u151-linux-x64.tar.gz -C /usr/local/java/
vim /etc/profile
JAVA_HOME=/usr/local/java/jdk1.8.0_151
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
export PATH JAVA_HOME CLASSPATH
source /etc/profile
java -version
- Continue compiled after installing java
5) Installation
make install
6) Create a log directory zabbix
mkdir -p /var/log/zabbix
chown -R zabbix:zabbix /var/log/zabbix/
7) Configuration zabbix_server profile
vim /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=nongkaige
8) zabbix_agent configuration profiles to achieve their own monitoring
vim /etc/zabbix/zabbix_agentd.conf
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
UnsafeUserParameters=1 #允许所有的字符是在用户定义的参数,参数传递,也就是支持自定义脚本
9) Start zabbix
/a01/apps/zabbix/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
/a01/apps/zabbix/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
- 报错:error while loading shared libraries: libmysqlclient.so.20: cannot open shared object file: No such file or directory
- Probably means can not find libmysqlclient.so.20, we see mysql installation directory should be a soft link up to:
ln -s /a01/apps/mysql/lib/libmysqlclient.so.20 /usr/local/lib
vim /etc/ld.so.conf
/usr/local/lib
- Run ldconfig command take effect after restarting success.
10) configured zabbix web page
mkdir -p /a01/apps/nginx/html/zabbix
cd /a01/apps/apps_src/zabbix-3.2.11/frontends/php/
cp -a . /a01/apps/nginx/html/zabbix/
11) Installation zabbix front end (http: // <server ip or host name> / zabbix)
- First restart the php-fpm
systemctl restart php-fpm
- 报错:PHP sockets extension missing (PHP configuration parameter --enable-sockets).
12) mounting extensions php sockets
- Into the php source package, use the tool to install phpize
cd /a01/apps/apps_src/php-7.1.7/ext/sockets/
/a01/apps/php7/bin/phpize
./configure --with-php-config=/a01/apps/php7/bin/php-config
make && make install
vim /etc/php/php.ini
[sockets]
extension = sockets.so
13) mounting extensions php ldap
yum -y install openldap-devel
- Always perform this step, otherwise the following will error: configure: error: Can not find ldap libraries in / usr / lib.
cp -frp /usr/lib64/libldap* /usr/lib
cd /a01/apps/apps_src/php-7.1.7/ext/ldap/
/a01/apps/php7/bin/phpize
./configure --with-php-config=/a01/apps/php7/bin/php-config
make && make install
vim /etc/php/php.ini
[ldap]
extension = ldap.so
14) Restart php-fpm
systemctl restart php-fpm
15) to refresh the page to continue installing the front zabbix
- Being given, we can put the image above to download the configuration file and then uploaded to the figure down to the specified directory, but zabbix under the web root directory already comes, we can go directly to modify
cd /a01/apps/nginx/html/zabbix/conf
cp zabbix.conf.php.example zabbix.conf.php
vim zabbix.conf.php
16) Next, close your browser will be able to revisit logged (default account: admin, password: zabbix)
17) into Chinese page
18) Modify the default password is nongkaige
19) arranged to monitor the machine
"Configuration" ----- "host" ----- "Enable"
20) Repair Chinese garbled
- Can be found in the figure above situation garbled into some box, we can go to download fonts, font, or go directly to copy some files to upload and modify the configuration on our win7 system.
- 1, go to the Control Panel win7 copy fonts
- 2, copy the font and upload it to the server
- 3, mv font to the specified directory, and modify the configuration file
cd /a01/apps/apps_src/
mv msyh.ttf /a01/apps/nginx/html/zabbix/fonts/
vim /a01/apps/nginx/html/zabbix/include/defines.inc.php
#修改45行
define('ZBX_GRAPH_FONT_NAME', 'msyh'); // font file name
#修改93行
define('ZBX_FONT_NAME', 'msyh');
- 4, refresh the page to see
21) Disable guest user
- "Management" ------ "User Group" ------ "disabled"
22) scripting to add zabbix-server system services
cd /etc/systemd/system
vim zabbix-server.service
[Unit]
Description=zabbix-server
After=network.target
[Service]
Type=forking
ExecStart=/a01/apps/zabbix/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
[Install]
WantedBy=multi-user.target
chmod 754 /etc/systemd/system/zabbix-server.service
systemctl enable zabbix-server
23) scripting to add zabbix-agentd to system services
cd /etc/systemd/system
vim zabbix-agentd.service
[Unit]
Description=zabbix-server
After=network.target
[Service]
Type=forking
ExecStart=/a01/apps/zabbix/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
[Install]
WantedBy=multi-user.target
chmod 754 /etc/systemd/system/zabbix-agentd.service
systemctl enable zabbix-agentd
- Well, this zabbix server has been deployed, and implemented monitoring zabbix the machine, take a look at the following renderings
(C) the client source code to compile and install Zabbix for agent-side for centos 6
1. Create a user runs zabbix
useradd -M -s /sbin/nologin zabbix
2. Unpack
cd /a01/apps/apps_src/
tar -zxvf zabbix-3.2.11.tar.gz
cd zabbix-3.2.11
3. Configuration
./configure --prefix=/a01/apps/zabbix --sysconfdir=/etc/zabbix --datadir=/a01/apps/zabbix/data --enable-agent
4. Install
make install
5. Create a log directory zabbix
mkdir -p /var/log/zabbix
chown -R zabbix:zabbix /var/log/zabbix/
6. Configure zabbix_agentd profile
vim /etc/zabbix/zabbix_agentd.conf
LogFile=/var/log/zabbix/zabbix_agentd.log
Server=192.168.10.21
ServerActive=192.168.10.21
Hostname=192.168.10.26
UnsafeUserParameters=1
7. cp source package comes with a script to add to the system service zabbix-agentd
cp /a01/apps/apps_src/zabbix-3.2.11/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/
vim /etc/init.d/zabbix_agentd
ZABBIX_BIN="/a01/apps/zabbix/sbin/zabbix_agentd" #修改
CONF_FILE="/etc/zabbix/zabbix_agentd.conf" #添加
daemon $ZABBIX_BIN -c $CONF_FILE #添加后边的-c $CONF_FILE
chkconfig --add zabbix_agentd
chkconfig --level 35 zabbix_agentd on
8. Start zabbix_agentd
service zabbix_agentd start
(Iv) to test whether the client and server communications zabbix
/a01/apps/zabbix/bin/zabbix_get -s 192.168.10.26 -p10050 -k"net.if.in[eth2,bytes]"
- The server can get information about the client's card, indicating that can communicate
(E) to the front-end web page creation zabbix Host monitoring client
- "Configuration" ------ "host" ------ "Create Host"