Zabbix 监控 Linux 主机


Zabbix 监控 Linux 主机-Opss
Zabbix 监控 Linux 主机-Opss

Zabbix监控Windows服务器

在上篇文章演示了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源
[root@lab-client ~]# rpm -ivh http://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

Retrieving http://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.QAVW1K: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-5.0-1.el7         ################################# [100%]
  • 安装Zabbix_agent
[root@lab-client ~]# yum -y install zabbix-agent

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package zabbix-agent.x86_64 0:5.0.6-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================
 Package                     Arch                  Version                     Repository             Size
===========================================================================================================
Installing:
 zabbix-agent                x86_64                5.0.6-1.el7                 zabbix                452 k

Transaction Summary
===========================================================================================================
Install  1 Package

Total download size: 452 k
Installed size: 1.8 M
Downloading packages:
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
Public key for zabbix-agent-5.0.6-1.el7.x86_64.rpm is not installed
zabbix-agent-5.0.6-1.el7.x86_64.rpm                                                 | 452 kB  00:01:25     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Importing GPG key 0xA14FE591:
 Userid     : "Zabbix LLC <packager@zabbix.com>"
 Fingerprint: a184 8f53 52d0 22b9 471d 83d0 082a b56b a14f e591
 Package    : zabbix-release-5.0-1.el7.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : zabbix-agent-5.0.6-1.el7.x86_64                                                         1/1 
  Verifying  : zabbix-agent-5.0.6-1.el7.x86_64                                                         1/1 

Installed:
  zabbix-agent.x86_64 0:5.0.6-1.el7                                                                        

Complete!
  • 修改zabbix-agent配置文件
[root@lab-client ~]# vim /etc/zabbix/zabbix_agentd.conf

#修改117行
Server=172.16.252.100 #此处填写Zabbix Server的IP地址
#修改158行
ServerActive=172.16.252.100 #此处填写Zabbix Server的IP地址
#修改169行
Hostname=lab-client #此处填写被监控主机电脑名
  • 启动zabbix_agent服务
#关闭防火墙此处演示,生产环境可放行10050端口即可
[root@lab-client ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

#启动Zabbix_agent服务并添加到自动启动
[root@lab-client ~]# systemctl start zabbix-agent.service && systemctl enable zabbix-agent.service

Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.

#查看zabbix_agent是否启动
[root@lab-client ~]#systemctl status zabbix-agent.service
● zabbix-agent.service - Zabbix Agent
   Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-12-15 03:25:02 PST; 27s ago
 Main PID: 32512 (zabbix_agentd)
   CGroup: /system.slice/zabbix-agent.service
           ├─32512 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
           ├─32513 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
           ├─32514 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
           ├─32515 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
           ├─32516 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
           └─32517 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

Dec 15 03:25:02 lab-client systemd[1]: Starting Zabbix Agent...
Dec 15 03:25:02 lab-client systemd[1]: Started Zabbix Agent.

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

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

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

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

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

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

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


给TA买糖
共{{data.count}}人
人已赞赏
文章教程

Windows Server 2019 部署 DHCP 服务

2020-12-15 9:49:41

文章教程

Windows Server 2019 域策略禁止电脑使用USB移动存储

2020-12-16 11:55:44

⚠️
运维社区资源内容收集整理于互联网仅用于测试学习环境下使用,如在生产环境使用后果自负!其著作权归原作者所有!
如果有侵犯您权利的资源,我们将及时下架相应资源,请联系:eOps@foxmail.com「需附上权利证明」或点击  运维社区QQ客服
个人中心
今日签到
搜索