zabbix
是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix
能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix
由2部分构成,zabbix server
与可选组件zabbix agent
。
zabbix server
可以通过SNMP
,zabbix agent
,ping
,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Ubuntu,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
zabbix agent
需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。
zabbix server
可以单独监视远程服务器的服务状态;同时也可以与zabbix agent
配合,可以轮询zabbix agent
主动接收监视数据(agent方式),同时还可被动接收zabbix agent
发送的数据(trapping方式)。
另外zabbix server
还支持SNMP (v1,v2),可以与SNMP软件(例如:net-snmp)等配合使用。
zabbix的主要特点:
Zabbix主要功能:
zabbix配置文件有两种:
服务器端配置文件zabbix_server.conf常用配置参数:
参数 | 作用 |
---|---|
LogFile | 设置服务端日志文件存放路径 |
ListenIP | 设置服务端监听IP |
ListenPort | 设置服务端监听的端口号 |
PidFile | 设置服务端进程号文件存放路径 |
DBHost | 指定zabbix的数据库服务器IP |
DBName | 指定zabbix使用的数据库库名 |
DBUser | 指定zabbix数据库登录用户 |
DBPassword | 指定zabbix数据库登录密码 |
DBPort | 指定zabbix数据库端口号 |
User | 设置zabbix以什么用户的身份运行 |
AlertScriptsPath | 设置告警脚本存放路径 |
ExternalScripts | 外部脚本存放路径 |
客户端配置文件zabbix_agentd.conf常用配置参数:
参数 | 作用 |
---|---|
Server | 指定zabbix服务器的IP或域名 |
ServerActive | 指定zabbix服务器的IP或域名 |
Hostname | 指定本机的主机名,此项必须与web界面配置项一致 |
UnsafeUserParameters | 是否启用自定义监控项,可选值为{1 |
UserParameter | 指定自定义监控脚本参数 |
LogFile | 设置客户端日志文件存放路径 |
环境说明:
环境 | IP | 要安装的应用 |
---|---|---|
服务器 | 192.168.142.133 | lamp架构 zabbix server zabbix agent |
因为zabbix
是用php
语言开发的,所以必须先部署lamp
架构,使其能够支持运行php
网页
//安装依赖关系
[root@cst ~]# yum -y install net-snmp-devel libevent-devel
//解压zabbix安装包
[root@cst ~]# tar xf zabbix-5.2.6.tar.gz
//创建zabbix系统用户
[root@cst ~]# useradd -r -M -s /sbin/nologin zabbix
//配置zabbix数据库
[root@cst ~]# mysql -uroot -p123
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by ‘123‘;
Query OK, 0 rows affected, 2 warnings (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@192.168.142.133 identtified by ‘123‘;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
[root@cst ~]# cd zabbix-5.2.6/database/mysql/
[root@cst mysql]# mysql -uzabbix -p123 zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@cst mysql]# mysql -uzabbix -p123 zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@cst mysql]# mysql -uzabbix -p123 zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
//编译安装zabbix
[root@cst ~]# cd zabbix-5.2.6/
[root@cst zabbix-5.2.6]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
[root@cst zabbix-5.2.6]# make install
//修改服务端配置文件
//设置数据库信息
[root@cst ~]# vim /usr/local/etc/zabbix_server.conf
### Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=123 //取消注释并设置zabbix数据库密码
[root@cst ~]# zabbix_server
[root@cst ~]# zabbix_agentd
[root@cst ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
//修改/etc/php.ini的配置并重启php-fpm
[root@cst ~]# sed -ri ‘s/(post_max_size =).*/\1 16M/g‘ /etc/php.ini
[root@cst ~]# sed -ri ‘s/(max_execution_time =).*/\1 300/g‘ /etc/php.ini
[root@cst ~]# sed -ri ‘s/(max_input_time =).*/\1 300/g‘ /etc/php.ini
[root@cst ~]# sed -i ‘/;date.timezone/a date.timezone = Asia/Shanghai‘ /etc/php.ini
[root@cst ~]# systemctl restart php-fpm.service
[root@cst ~]# mkdir /usr/local/apache/htdocs/zabbix
[root@cst ~]# cp -r zabbix-5.2.6/ui/* /usr/local/apache/htdocs/zabbix/
[root@cst ~]# chown -R apache.apache /usr/local/apache/htdocs
[root@cst ~]# vim /etc/httpd24/httpd.conf
<VirtualHost *:80> DocumentRoot "/usr/local/apache/htdocs/zabbix" ServerName www.cst123.com ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1
<Directory "/usr/local/apache/htdocs/zabbix">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
[root@cst ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
//设置开机自动启动
[root@cst zabbix-5.2.6]# cp -r misc/init.d/fedora/core/* /etc/init.d/
[root@cst zabbix-5.2.6]# chmod 775 /etc/init.d/zabbix_*
[root@cst zabbix-5.2.6]# sed -i ‘s/BASEDIR=\/usr\/local/&\/zabbix/g‘ /etc/init.d/zabbix_server
[root@cst zabbix-5.2.6]# sed -i ‘s/BASEDIR=\/usr\/local/&\/zabbix/g‘ /etc/init.d/zabbix_agentd
原文:https://www.cnblogs.com/sarenn/p/14630381.html