01.Linux CentOS 7安装Zabbix agent的方法
应用场景:
Zabbix监控系统提供两种监控Linux主机的方法,一种是启用主机上的SNMP协议,另一种是在主机上安装Zabbix Agent服务,本篇介绍Linux系统下Zabbix Agent的安装与使用。
1.添加Repository
本文使用yum方式安装Zabbix Agent,在安装前首先添加对应的yum repository,以下列出了CentOS/RHEL版本的添加地址:
##CentOS/RHEL 7:
[root@localhost ~]# rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
##CentOS/RHEL 6:
[root@localhost ~]# rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
2.安装Zabbix Agent
[root@localhost ~]# yum install zabbix-agent
3.修改zabbix agent端的配置文件
1) 将需要修改的内容如下所示
[root@Zabbix_Server ~]# cd /etc/zabbix/
[root@localhost zabbix ]# cat -n zabbix_agentd.conf | sed -n '13p;32p;95p;103p;120p;136p;147p;265p;284p'
13 PidFile=/var/run/zabbix/zabbix_agentd.pid
32 LogFile=/var/log/zabbix/zabbix_agentd.log
95 Server=127.0.0.1
103 # ListenPort=10050
120 # StartAgents=3
136 ServerActive=127.0.0.1
147 Hostname=Zabbix server
265 Include=/etc/zabbix/zabbix_agentd.d/*.conf
284 # UnsafeUserParameters=0
2) 将内容修改为如下所示
[root@localhost zabbix]# cat -n zabbix_agentd.conf | sed -n '13p;32p;95p;103p;120p;136p;147p;265p;284p'
13 PidFile=/var/run/zabbix/zabbix_agentd.pid #进程pid存放路径
32 LogFile=/var/log/zabbix/zabbix_agentd.log #zabbix agent日志存放路径
95 Server=127.0.0.1,192.168.0.220 #指定zabbix server端IP地址
103 ListenPort=10050 #指定agentd的监听端口
120 StartAgents=3 #指定启动agentd进程数量。设置0表示关闭
136 ServerActive=192.168.0.220:10051 #启用agnetd主动模式,启动主动模式后,agentd将主动将收集到的数据发送到zabbix server端,Server Active后面指定的IP就是zabbix server端IP
147 Hostname=192.168.0.220 #需要监控服务器的主机名或者IP地址,此选项的设置一定要和zabbix web端主机配置中对应的主机名一致。
265 Include=/etc/zabbix/zabbix_agentd.d/ #相关配置都可以放到此目录下,自动生效
284 UnsafeUserParameters=1 #启用agent端自定义item功能,设置此参数为1后,就可以使用UserParameter指令了。UserParameter用于自定义item
4.给配置文件授权
[root@localhost zabbix]# chmod 775 /etc/zabbix/zabbix_agentd.conf
5.启动agent服务并查看服务启动成功没有
[root@localhost ~]# /etc/init.d/zabbix-agent start
Starting Zabbix agent: [ OK ]
[root@localhost ~]# netstat -antup | grep zabbix_agent
6.添加开机启动
[root@localhost init.d]# chkconfig zabbix-agent on
好了,到这里使用Linux上安装Zabbix agent的方法就结束了,如果大家在安装配置过程中有问题,评论即可,会第一时间回复大家。