2

Zabbix 监控 Linux 主机

 2 years ago
source link: https://www.opsit.cn/6741.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

在上篇文章演示了Zabbix监控Windows 主机,这篇文章将演示Zabbix监控Linux主机配置操作。

0x01 准备工作

  • 准备好需要被监控Linux主机需与Zabbix Server正常通信

    Zabbix Server

    OS:CentOS 7.4

    Hostname:Zabbix

    IP:172.16.252.100

    已安装部署好Zabbix 5.0.6

    Zabbix Client

    OS:CentOS 7.4

    Hostname:Lab-client

    IP:172.16.252.111

0x02 安装Zabbix Agent

  • 安装Zabbix 5.0 yum源
  1. [root@lab-client ~]# rpm -ivh http://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
  2. Retrieving http://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
  3. warning: /var/tmp/rpm-tmp.QAVW1K: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
  4. Preparing... ################################# [100%]
  5. Updating / installing...
  6. 1:zabbix-release-5.0-1.el7 ################################# [100%]
  • 安装Zabbix_agent
  1. [root@lab-client ~]# yum -y install zabbix-agent
  2. Loaded plugins: fastestmirror, langpacks
  3. Loading mirror speeds from cached hostfile
  4. * base: mirrors.ustc.edu.cn
  5. * extras: mirrors.aliyun.com
  6. * updates: mirrors.aliyun.com
  7. Resolving Dependencies
  8. --> Running transaction check
  9. ---> Package zabbix-agent.x86_64 0:5.0.6-1.el7 will be installed
  10. --> Finished Dependency Resolution
  11. Dependencies Resolved
  12. ===========================================================================================================
  13. Package Arch Version Repository Size
  14. ===========================================================================================================
  15. Installing:
  16. zabbix-agent x86_64 5.0.6-1.el7 zabbix 452 k
  17. Transaction Summary
  18. ===========================================================================================================
  19. Install 1 Package
  20. Total download size: 452 k
  21. Installed size: 1.8 M
  22. Downloading packages:
  23. warning: /var/cache/yum/x86_64/7/zabbix/packages/zabbix-agent-5.0.6-1.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
  24. Public key for zabbix-agent-5.0.6-1.el7.x86_64.rpm is not installed
  25. zabbix-agent-5.0.6-1.el7.x86_64.rpm | 452 kB 00:01:25
  26. Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
  27. Importing GPG key 0xA14FE591:
  28. Userid : "Zabbix LLC <[email protected]>"
  29. Fingerprint: a184 8f53 52d0 22b9 471d 83d0 082a b56b a14f e591
  30. Package : zabbix-release-5.0-1.el7.noarch (installed)
  31. From : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
  32. Running transaction check
  33. Running transaction test
  34. Transaction test succeeded
  35. Running transaction
  36. Installing : zabbix-agent-5.0.6-1.el7.x86_64 1/1
  37. Verifying : zabbix-agent-5.0.6-1.el7.x86_64 1/1
  38. Installed:
  39. zabbix-agent.x86_64 0:5.0.6-1.el7
  40. Complete!
  • 修改zabbix-agent配置文件
  1. [root@lab-client ~]# vim /etc/zabbix/zabbix_agentd.conf
  2. #修改117行
  3. Server=172.16.252.100 #此处填写Zabbix Server的IP地址
  4. #修改158行
  5. ServerActive=172.16.252.100 #此处填写Zabbix Server的IP地址
  6. #修改169行
  7. Hostname=lab-client #此处填写被监控主机电脑名
  • 启动zabbix_agent服务
  1. #关闭防火墙此处演示,生产环境可放行10050端口即可
  2. [root@lab-client ~]# systemctl disable firewalld
  3. Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
  4. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
  5. #启动Zabbix_agent服务并添加到自动启动
  6. [root@lab-client ~]# systemctl start zabbix-agent.service && systemctl enable zabbix-agent.service
  7. Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
  8. #查看zabbix_agent是否启动
  9. [root@lab-client ~]#systemctl status zabbix-agent.service
  10. ● zabbix-agent.service - Zabbix Agent
  11. Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
  12. Active: active (running) since Tue 2020-12-15 03:25:02 PST; 27s ago
  13. Main PID: 32512 (zabbix_agentd)
  14. CGroup: /system.slice/zabbix-agent.service
  15. ├─32512 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
  16. ├─32513 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
  17. ├─32514 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
  18. ├─32515 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
  19. ├─32516 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
  20. └─32517 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
  21. Dec 15 03:25:02 lab-client systemd[1]: Starting Zabbix Agent...
  22. Dec 15 03:25:02 lab-client systemd[1]: Started Zabbix Agent.

0x03 控制端新增被监控主机

  • 进入控制端后,首先新增主机群组Linux-CentOS

88f5608832a8dbb_1_post.png

88dd1af8f58a08f_1_post.png

  • 创建CentOS模板群组,将上一步新建的Linux-CentOS主机群组加入,并链接到Template OS Linux by Zabbix agent基础模板 (此处演示用,使用自带基础模板)

888552b88a8daf0_1_post.png

88c7f7a8b853d4e_1_post.png

  • 新增主机,并将lab-client主机添加到Linux-CentOS主机群组中

8888298d8cba05f_1_post.png

8885f8edaa828b2_1_post.png

88f6a152d8285c0_1_post.png

  • 看到主机状态中ZBX变绿了,即证明安装成功,可以被正常监控

8899e84482adfd5_1_post.png

  • 验证查看主机运行状态图形显示

8857aa80e8d8cff_1_post.png

可以正常看到主机当前CPU运行状态,到此已完成通过Zabbix监控Linux主机配置动作,其他更深入的监控项以及触发器操作后续会依次实验。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK