前言:
zabbix agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。zabbix agent可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD, OS X, Tru64/OSF1, Windows NT4.0, Windows (2000/2003/XP/Vista)等系统之上。
CentOS 7 yum安装Zabbix
一、准备工作:
1、关闭防火墙(为了方便测试)
[root@localhost ~]#systemctl stop firewalld
[root@localhost ~]systemctl disable firewalld.service
注:如果使用yum过程中出现“yum Cannot find a valid baseurl for repo: base/7/x86_64”问题,请参考:https://blog.csdn.net/weixin_37973929/article/details/85317619 解决
如果出现:“Another app is currently holding the yum lock; waiting for it to exit...”问题,请参考:https://blog.csdn.net/weixin_37973929/article/details/85246422 解决
2、配置源
[root@localhost ~]#wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
[root@localhost ~]#rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
二、安装agent:
1、生成yum源快照,这样可以直接用tab键来补全安装:
yum makecache
2、查看文件:
[root@localhost ~]# yum search zabbix
3、选择zabbix-agent安装:
yum install zabbix-agent
4、修改agent配置文件:
vi /etc/zabbix/zabbix_agentd.conf
-----------------解读--------------------------
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=zabbix-service机器IP
ServerActive=zabbix-service机器IP
Hostname=本机IP
Include=/etc/zabbix/zabbix_agentd.d/
以上配置完毕后,我们在zabbix web端添加该监控机器时,只需要把honst name与该配置文件中的hostname对应即可。如下:
5、启动客户端
[root@zabbix ~]# zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
[root@zabbix ~]# systemctl start zabbix-agent
[root@zabbix ~]# systemctl restart zabbix-agent
[root@zabbix ~]# systemctl enable zabbix-agent
三、验证
我们来验证客户机与服务器之间是否可同,agent是有能够取到返回值。
1、服务器telnet客户机的10050
telnet 客户机IP 10050
输出:
Trying 192.168.81.134...
Connected to 192.168.81.134.
Escape character is '^]'.
2、客户机telnet服务器的10051
telnet 服务器IP 10051
输出:
Trying 192.168.81.129...
Connected to 192.168.81.129.
Escape character is '^]'.
3、服务器去客户机取返回值
zabbix_get -s 客户机IP -k agent.ping
输出:
1