1、zabbix简介
Zabbix 是一个高度集成的网络监控解决方案,可以提供企业级的开源分布式监控解决方案,由一个国外的团队持续维护更新,软件可以自由下载使用,运作团队靠提供收费的技术支持赢利。
zabbix 是一个基于 Web 界面的,提供分布式系统监控以及网络监视功能的企业级的开源解决方案。
zabbix 能监视各种网络参数,保证服务器系统的安全运营,并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
2、zabbix架构
3、Zabbix 功能
①具备常见的商业监控软件所具备的功能(主机的性能监控、网络设备性能监控、数据库、性能监控、FTP 等通用协议监控、多种告警方式、详细的报表图表绘制)
②支持自动发现网络设备和服务器(可以通过配置自动发现服务器规则来实现)
③支持自动发现(low discovery)key 实现动态监控项的批量监控(需写脚本)
④支持分布式,能集中展示、管理分布式的监控点
⑤扩展性强,server 提供通用接口(api 功能),可以自己开发完善各类监控(根据相关接口编写程序实现)编写插件容易,可以自定义监控项,报警级别的设置。
⑥数据收集
1、环境配置
cd /etc/sysconfig/network-scripts/
vi ifcfg-eth0
hostnamectl set-hostname zabbix-server
[root@zabbix-server ~]# systemctl stop firewalld
[root@zabbix-server ~]# systemctl disable firewalld
[root@zabbix-server ~]# sed -i 's/=enforcing/=disabled/' /etc/sysconfig/selinux
[root@zabbix-server ~]# sed -i 's/=enforcing/=disabled/' /etc/selinux/config
[root@zabbix-server ~]# setenforce 0
setenforce: SELinux is disabled
yum install net-tools bash-completion wget vim ntpdate -y
2、准备 LAMP 环境
yum install httpd mariadb mariadb-server php php-mysql php-gd -y
3、配置 zabbix yum 源
[root@zabbix-server ~]# vi /etc/yum.repos.d/zabbix.repo
[root@zabbix-server ~]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - \$basearch
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/\$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - \$basearch
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/\$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
添加 gpgkey
[root@zabbix-server ~]# curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX-A14FE591 -o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[root@zabbix-server ~]# curl https://mirrors.aliyun.com/zabbix/RPM-GPG-KEY-ZABBIX -o /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
4、安装zabbix server
[root@zabbix-server ~]# yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
[root@zabbix-server ~]# rpm -aq |grep zabbix
zabbix-server-mysql-4.0.8-1.el7.x86_64
zabbix-web-mysql-4.0.8-1.el7.noarch
zabbix-agent-4.0.8-1.el7.x86_64
zabbix-web-4.0.8-1.el7.noarch
再安装zabbix-release
yum install https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
[root@zabbix-server ~]# rpm -aq |grep zabbix
zabbix-release-4.0-1.el7.noarch
zabbix-server-mysql-4.0.8-1.el7.x86_64
zabbix-web-mysql-4.0.8-1.el7.noarch
zabbix-agent-4.0.8-1.el7.x86_64
zabbix-web-4.0.8-1.el7.noarch
修改PHP时区
sed -i 's@# php_value date.timezone Europe/Riga@php_value date.timezone Asia/Shanghai@g' /etc/httpd/conf.d/zabbix.conf
5、数据库设置
启动数据库
[root@zabbix-server ~]# systemctl start mariadb
[root@zabbix-server ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
创建 zabbix 数据库及用户
[root@zabbix-server ~]# mysql -e "create database zabbix character set utf8;"
[root@zabbix-server ~]# mysql -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';"
[root@zabbix-server ~]# mysqladmin flush-privileges
导入数据库
cd /usr/share/doc/zabbix-server-mysql-4.0.8/
You have new mail in /var/spool/mail/root
[root@zabbix-server zabbix-server-mysql-4.0.8]# zcat create.sql.gz | mysql -uzabbix -p zabbix
Enter password:(密码为zabbix)
[root@zabbix-server zabbix-server-mysql-4.0.8]# mysql -uzabbix -p -e 'use zabbix;show tables;'
Enter password:(密码为zabbix)
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_suppress |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| hstgrp |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| items |
| items_applications |
| maintenance_tag |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| tag_filter |
| task |
| task_acknowledge |
| task_check_now |
| task_close_problem |
| task_remote_command |
| task_remote_command_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+----------------------------+
6、修改 zabbix 配置文件
[root@zabbix-server ~]# vi /etc/zabbix/zabbix_server.conf
[root@zabbix-server ~]# grep ^DB /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
修改主要参数即可正常工作
DBName=zabbix 数据库名称
DBUser=zabbix 数据库用户
DBPassword=zabbix 数据库密码
7、启动 zabbix 及 apache
[root@zabbix-server ~]# systemctl restart zabbix-server.service httpd.service
[root@zabbix-server ~]# systemctl enable zabbix-server.service httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@zabbix-server ~]# netstat -lnupt | egrep '80|10051'
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 33467/zabbix_server
tcp6 0 0 :::80 :::* LISTEN 33465/httpd
tcp6 0 0 :::10051 :::* LISTEN 33467/zabbix_server
8、Web 界面安装 master
在浏览器输入http://192.168.65.144/zabbix/setup.php
修改文件权限,再点击下一步
chmod 777 /usr/share/zabbix/assets
登录成功后,点击右上角人头,修改信息
设置新密码并选择中文
10、解决 zabbix 中文乱码方法:
解决方法:
1)上传文件到 zabbix 中
找到本地 C:\Windows\Fonts\ simkai.ttf(楷体)上传到服务器 zabbix 网站目录fonts 目录下。
字体目录为:/usr/share/zabbix/assets/fonts
[root@zabbix-server ~]# cd /usr/share/zabbix/assets/fonts/
[root@zabbix-server fonts]# ls
simkai.ttf
2)、修改 zabbix php 配置文件
[root@zabbix-server fonts]# sed -i 's/graphfont/simkai/g' /usr/share/zabbix/include/defines.inc.php