文章目录
1.zabbix介绍
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)等配合使用。
2. zabbix特点
zabbix的主要特点:
1.安装与配置简单,学习成本低
2.支持多语言(包括中文)
3.免费开源
4.自动发现服务器与网络设备
5.分布式监视以及WEB集中管理功能
6.可以无agent监视
7.用户安全认证和柔软的授权方式
8.通过WEB界面设置或查看监视结果
9.email等通知功能
Zabbix主要功能:
1.CPU负荷
2.内存使用
3.磁盘使用
4.网络状况
5.端口监视
6.日志监视
3.zabbix配置文件
zabbix配置文件有两种:
服务器端配置文件(/usr/local/etc/zabbix_server.conf)
客户端配置文件(/usr/local/etc/zabbix_agentd.conf)
zabbix代理配置文件(/usr/local/etc/zabbix_proxy.conf)
服务器端配置文件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 | 设置客户端日志文件存放路径 |
4.部署zabbix
环境
环境 | ip | 要安装的应用 |
---|---|---|
服务端 | 192.168.56.128 | lamp架构、zabbix server、zabbix agent |
客户端 | 192.168.56.129 | zabbix agent |
zabbix服务端的安装
[root@psr1 ~]# yum -y install net-snmp-devel libevent-devel
[root@psr1 ~]# mv zabbix-4.0.4.tar.gz /usr/src/
[root@psr1 ~]# cd /usr/src/
[root@psr1 src]# tar xf zabbix-4.0.4.tar.gz
[root@psr1 src]# groupadd -r zabbix
[root@psr1 src]# useradd -r -g zabbix -M -s /sbin/nologin zabbix
[root@psr1 src]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.23 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.06 sec)
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123!';
Query OK, 0 rows affected, 2 warnings (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
[root@psr1 ~]# cd /usr/src/zabbix-4.0.4/database/mysql/
[root@psr1 mysql]# ls
data.sql images.sql Makefile.am Makefile.in schema.sql
[root@psr1 mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@psr1 mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@psr1 mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@psr1 mysql]# cd /usr/src/zabbix-4.0.4/
[root@psr1 zabbix-4.0.4]# ./configure --enable-server \
> --enable-agent \
> --with-mysql \
> --with-net-snmp \
> --with-libcurl \
> --with-libxml2
[root@psr1 zabbix-4.0.4]# make install
[root@psr1 ~]# ls /usr/local/e