一、环境介绍

Zabbix Agent  for Linux部署(四)-LMLPHP

二、代理安装

1、将代理程序拷贝至Node1服务器的/usr/src/zabbix3.4.5/目录下

[root@Node3 zabbix3.4.5]# scp zabbix-agent-3.4.-.el7.x86_64.rpm zabbix-sender-3.4.-.el7.x86_64.rpm  root@node1:/usr/src/zabbix3.4.5/
root@node1's password:
zabbix-agent-3.4.-.el7.x86_64.rpm % 359KB .9MB/s :
zabbix-sender-3.4.-.el7.x86_64.rpm % 260KB .2MB/s :

2、代理通过yum的方式来安装

[root@Node1 zabbix3.4.5]# yum install -y *.rpm ./      //通过yum方式安装当前目录下的rpm包
Loaded plugins: fastestmirror, langpacks
Examining zabbix-agent-3.4.-.el7.x86_64.rpm: zabbix-agent-3.4.-.el7.x86_64
Marking zabbix-agent-3.4.-.el7.x86_64.rpm to be installed
Examining zabbix-sender-3.4.-.el7.x86_64.rpm: zabbix-sender-3.4.-.el7.x86_64
Marking zabbix-sender-3.4.-.el7.x86_64.rpm to be installed
CentOS7. | 3.6 kB ::
(/): CentOS7./group_gz | kB ::
(/): CentOS7./primary_db | 3.1 MB ::
Determining fastest mirrors
No package ./ available.
Resolving Dependencies
--> Running transaction check
---> Package zabbix-agent.x86_64 :3.4.-.el7 will be installed
---> Package zabbix-sender.x86_64 :3.4.-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =====================================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================================
Installing:
zabbix-agent x86_64 3.4.-.el7 /zabbix-agent-3.4.-.el7.x86_64 1.4 M
zabbix-sender x86_64 3.4.-.el7 /zabbix-sender-3.4.-.el7.x86_64 1.0 M Transaction Summary
=====================================================================================================================================================
Install Packages Total size: 2.4 M
Installed size: 2.4 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : zabbix-sender-3.4.-.el7.x86_64 /
Installing : zabbix-agent-3.4.-.el7.x86_64 /
Verifying : zabbix-agent-3.4.-.el7.x86_64 /
Verifying : zabbix-sender-3.4.-.el7.x86_64 / Installed:
zabbix-agent.x86_64 :3.4.-.el7 zabbix-sender.x86_64 :3.4.-.el7 Complete!
[root@Node1 zabbix3.4.5]# id zabbix
uid=(zabbix) gid=(zabbix) groups=(zabbix)
[root@Node1 zabbix3.4.5]#

3、修改/etc/zabbix/zabbix_agentd.conf配置文件

[root@Node1 ~]# vim /etc/zabbix/zabbix_agentd.conf
[root@Node1 ~]# grep -n "^[a-Z]" /etc/zabbix/zabbix_agentd.conf
:PidFile=/var/run/zabbix/zabbix_agentd.pid
:LogFile=/var/log/zabbix/zabbix_agentd.log
:LogFileSize=
:DebugLevel=3 //日志级别,默认为3
:Server=172.17.21.208 //用于被动模式,数据获取
:ServerActive=172.17.21.208 //用于主动模式,数据提交
:Hostname=Node1.contoso.com //必须与创建主机时的hostname一致
:Include=/etc/zabbix/zabbix_agentd.d/*.conf //包含子配置文件的路径
:UnsafeUserParameters=1 //允许所有字符的参数传递给用户定义的参数,默认为0,即没有启用

4、启动zabbix_agent服务器,并设置开机自启动

[root@Node1 ~]# systemctl start zabbix-agent.service
[root@Node1 ~]# 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.
[root@Node1 ~]# ss -tnl | grep
LISTEN 127.0.0.1: *:*
LISTEN *: *:*
LISTEN ::: :::*
LISTEN ::: :::*

三、Zabbix Server上添加主机

1、点击Configuration-->Hosts-->Greate host,然后点击Add,进行添加即可
Zabbix Agent  for Linux部署(四)-LMLPHP

2、点击添加之后,进入Configuration-->Hosts界面进行模板关联
Zabbix Agent  for Linux部署(四)-LMLPHP

3、选择 Node1节点这后,点击Templates,选择所需要的模板进行关联,然后点击Add,然后Update即可
Zabbix Agent  for Linux部署(四)-LMLPHP

4、然后看到以下界面,说明模板已经关联,发现ZBX为绿色,代表正常:

Zabbix Agent  for Linux部署(四)-LMLPHP

5、在zabbix服务器获取相关参数值:

[root@Node3 zabbix3.4.5]# zabbix_get -s 172.17.21.206 -p  -k "system.hostname"      //获取主机名
Node1.contoso.com
[root@Node3 zabbix3.4.5]# zabbix_get -s 172.17.21.206 -p -k "system.uptime" //运行时间 [root@Node3 zabbix3.4.5]# zabbix_get -s 172.17.21.206 -p -k "vm.memory.size[total]" //获取总内存,以下为4G [root@Node3 zabbix3.4.5]#

6、在Web界面查看可用内存如下:

Zabbix Agent  for Linux部署(四)-LMLPHP

05-23 19:54