zabbix agent安装
1,安装zabbix软件包的yum源
1.1 登陆官网 https://www.zabbix.com/download,选择对应的操作系统版本后,使用rpm命令安装。
rpm -i https://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm
rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/6/x86_64/zabbix-release-4.0-2.el6.noarch.rpm #4.0长期支持版
1.2 yum clean all && yum -y install zabbix-agent
1.3 vi /etc/zabbix/zabbix_agentd.conf 修改下几项
Server=10.195.236.135
ListenPort=10050
ServerActive=10.195.236.135 #主动模式server
Hostname=10.195.236.185 #zabbix添加host的主机名称,最好使用IP地址
RefreshActiveChecks=120
BufferSize=100
UnsafeUserParameters=1 #以下三行用户自定义监控项
UserParameter=memUse,/usr/bin/free | awk '/^-/{print$3}'
UserParameter=memTotal,/usr/bin/free | awk '/^Mem:/{print$2}'
UserParameter=cpuIdle,/usr/bin/top -bn 1 | awk -F '[ %]' '/^Cpu/{print$11}' #centos6 客户端系统cpu使用率
或者使用命令修改基本项
# 修改zabbix-server地址 sed -i 's/Server=127.0.0.1/Server=10.195.236.135/g' /etc/zabbix/zabbix_agentd.conf # 启用默认监听端口 sed -i 's/# ListenPort=10050/ListenPort=10050/g' /etc/zabbix/zabbix_agentd.conf # 启用主动模式,zabbix-server地址 sed -i 's/ServerActive=127.0.0.1/ServerActive=10.195.236.135/g' /etc/zabbix/zabbix_agentd.conf # 修改客户端本机主机名称,一般使用本机ip地址 sed -i 's/Hostname=Zabbix server/Hostname=10.195.236.175/g' /etc/zabbix/zabbix_agentd.conf
1.4 启动zabbix-agent 服务,service zabbix-agent start 或者systemctl start zabbix-agent
注意,一定要选择正确的操作系统版本,否则安装yum源会出错。若yum install zabbix-agent 报错(Error: Cannot retrieve repository metadata (repomd.xml) for repository: zabbix.)使用yum clean all 和rm -rf /var/cache/yum/* 清除yum缓存后重试