Zabbix监控系统

  • zabbix是一个基于WEB界面的提供分布式系统监控以及网络监控功能的企业级开源监控套件。

zabbix服务部署安装

一、启动LNMP环境

二、添加163源及zabbix ali内源

  1. [root@localhost html]# cat /etc/yum.repos.d/CentOS-Base.repo
  2. [base]
  3. name=CentOS-$releasever - Base - 163.com
  4. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
  5. baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
  6. gpgcheck=1
  7. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
  8. #released updates
  9. [updates]
  10. name=CentOS-$releasever - Updates - 163.com
  11. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
  12. baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
  13. gpgcheck=1
  14. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
  15. #additional packages that may be useful
  16. [extras]
  17. name=CentOS-$releasever - Extras - 163.com
  18. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
  19. baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
  20. gpgcheck=1
  21. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
  22. #additional packages that extend functionality of existing packages
  23. [centosplus]
  24. name=CentOS-$releasever - Plus - 163.com
  25. baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
  26. gpgcheck=1
  27. enabled=0
  28. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
  29. [root@localhost html]# cat /etc/yum.repos.d/zabbix.repo
  30. [zabbix]
  31. name=Zabbix Official Repository - \$basearch
  32. baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/\$basearch/
  33. enabled=1
  34. gpgcheck=1
  35. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
  36. [zabbix-non-supported]
  37. name=Zabbix Official Repository non-supported - \$basearch
  38. baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/\$basearch/
  39. enabled=1
  40. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
  41. gpgcheck=1

三、安装所需依赖

  1. [root@localhost html]# yum -y install net-snmp-devel libxml2-devel libcurl-deve libevent libevent-devel

四、安装zabbix

  1. [root@localhost html]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-agent

五、配置数据库

  • 创建初始化数据库
  1. [root@localhost html]# mysql -uroot -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 11
  5. Server version: 8.0.23 MySQL Community Server - GPL
  6. Copyright (c) 2000, 2021, Oracle and/or its affiliates.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> create database zabbix character set utf8 collate utf8_bin;
  12. Query OK, 1 row affected, 2 warnings (0.02 sec)
  13. mysql> create user 'zabbix'@'localhost' identified with mysql_native_password by 'Com.123456';
  14. Query OK, 0 rows affected (0.01 sec)
  15. mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
  16. Query OK, 0 rows affected (0.00 sec)
  17. mysql> quit
  • 导入数据
  1. [root@localhost html]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
  2. Enter password:
  • 配置zabbix server 数据库
  1. [root@localhost html]# vim /etc/zabbix/zabbix_server.conf
  2. DBPassword=Com.123456

六、Zabbix frontend配置PHP

  1. ##调整nginx配置文件
  2. [root@localhost html]# mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
  3. [root@localhost html]# vim /etc/nginx/conf.d/zabbix.conf
  4. listen 80;
  5. server_name example.com;
  6. ##调整到正确时区
  7. [root@localhost html]# vim /etc/php-fpm.d/zabbix.conf
  8. user = nginx
  9. group = nginx
  10. php_value[date.timezone] = Asia/Shanghai
  11. [root@zabbix-server zabbix]# systemctl enable zabbix-server.service zabbix-agent.service
  12. [root@zabbix-server zabbix]# systemctl start zabbix-server.service zabbix-agent.service
  13. [root@zabbix-server zabbix]#chown nginx:nginx /etc/zabbix/web/
  14. [root@zabbix-server zabbix]#啥chown nginx:nginx /var/lib/php/session/
  • 通过IP访问即可
    Zabbix4.4 - 图1
  • 进入zabbix
    Zabbix4.4 - 图2

七、添加中文字体

  • 将字体文件发送到服务器中
  1. C:\Windows\Fonts>scp simkai.ttf root@192.168.123.131:/usr/share/zabbix/assets/fonts/simkai.ttf
  2. The authenticity of host '192.168.123.131 (192.168.123.131)' can't be established.
  3. ECDSA key fingerprint is SHA256:4p2nndFcBY2oWhDDImh2mkQ+R120jqrbO5n9+wWLzw4.
  4. Are you sure you want to continue connecting (yes/no/[fingerprint])?
  5. Warning: Permanently added '192.168.123.131' (ECDSA) to the list of known hosts.
  6. root@192.168.123.131's password:
  7. simkai.ttf 100% 11MB 47.4MB/s 00:00
  8. [root@zabbix-server zabbix]# vim /usr/share/zabbix/include/defines.inc.php
  9. define('ZBX_GRAPH_FONT_NAME', 'simkai'); // font file name
  10. define('ZBX_FONT_NAME', 'simkai');
  11. ##原先的名字为:graphfont
  12. ##修改完毕后,刷新界面即可
  • 访问
    Zabbix4.4 - 图3

八、添加一台linux服务器

  • 安装zabbix_agentd
  1. [root@tomcat ~]# yum install zabbix-agent -y --nogpgcheck
  2. 已加载插件:fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. epel/x86_64/metalink | 3.5 kB 00:00:00
  5. * epel: mirrors.bfsu.edu.cn
  6. * webtatic: us-east.repo.webtatic.com
  7. 正在解决依赖
  8. ··········
  9. 已安装:
  10. zabbix-agent.x86_64 0:4.4.10-1.el7
  11. 完毕!
  • 修改配置文件
  1. [root@tomcat ~]# vim /etc/zabbix/zabbix_agentd.conf
  2. Server=192.168.123.131
  3. ServerActive=192.168.123.131
  4. Hostname=web01
  • 启动服务关闭防火墙或放行相应端口
  1. [root@tomcat ~]# systemctl disable firewalld
  2. [root@tomcat ~]# systemctl stop firewalld
  3. [root@tomcat ~]# systemctl enable zabbix-agent.service
  4. [root@tomcat ~]# systemctl start zabbix-agent
  5. [root@tomcat ~]# systemctl status zabbix-agent
  6. zabbix-agent.service - Zabbix Agent
  7. Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; disabled; vendor preset: disabled)
  8. Active: active (running) since 2021-04-09 15:57:04 CST; 7s ago

九、添加带zabbix监控系统组

Zabbix4.4 - 图4

十、添加需要关注的图表

Zabbix4.4 - 图5

一、配置交换机

  1. [sw1]interface Vlanif 1
  2. [sw1-Vlanif1]dis th
  3. #
  4. interface Vlanif1
  5. ip address 192.168.123.145 255.255.255.0
  6. #
  7. return
  8. [sw1]dis th
  9. #
  10. sysname sw1
  11. #
  12. undo info-center enable
  13. #
  14. cluster enable
  15. ntdp enable
  16. ndp enable
  17. #
  18. drop illegal-mac alarm
  19. #
  20. snmp-agent
  21. snmp-agent local-engineid 800007DB034C1FCCC81F9E
  22. snmp-agent community write redhat
  23. snmp-agent sys-info version all
  24. snmp-agent trap enable
  25. #
  26. return

二、开启zabbix的snmp服务并放行端口(防火墙已关闭)

  1. [root@localhost ~]# systemctl start snmptrapd.service snmpd.service

三、在Zabbix添加该设备

Zabbix4.4 - 图6

四、创建监控图形

Zabbix4.4 - 图7

  • 监控
    Zabbix4.4 - 图8