1.下载并且安装
cd /data/tools/
##切换到下载客户端目录
yum -y install zabbix-agent
##安装客户端
2.安装完后我们后面经常使用的文件如路径如下
/etc/zabbix/zabbix_agentd.conf
##zabbix_agentd配置文件
/etc/zabbix/zabbix_agentd.d
##zabbix_agentd进程文件
/var/run/zabbix/zabbix_agentd.pid
##zabbix_agentd pid文件路径
/var/log/zabbix/zabbix_agentd.log
##zabbix_agentd日志文件路径
3.修改配置文件
mv /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.confbak
##备份配置
cat /etc/zabbix/zabbix_agentd.confbak | egrep -v '^$|#'> zabbix_agentd.conf
##过滤一下空白行和注释
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agentd.d/*.conf
###Server和ServerActive上配置的是zabbix server的ip Hostname建议为客户端主机名
4. 启动、停止、检查 zabbix_ agentd
systemctl start zabbix-agent.service
###启动zabbix_agentd
systemctl stop zabbix-agent.service
###停止zabbix_agentd
systemctl status zabbix-agent.service
###查看zabbix_agentd状态
5.设置开机自启动
systemctl enable zabbix-agent.service
查看方式一:
[root@host zabbix]# 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 Fri 2019-06-21 00:57:27 CST; 18min ago
Main PID: 4475 (zabbix_agentd)
CGroup: /system.slice/zabbix-agent.service
├─4475 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
├─4476 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
├─4477 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
├─4478 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
├─4479 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
└─4480 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
Jun 21 00:57:27 host-172-16-54-151 systemd[1]: Starting Zabbix Agent...
Jun 21 00:57:27 host-172-16-54-151 systemd[1]: Started Zabbix Agent.
此片变成enabled说明开机自启动设置成功
查看方式二:
[root@host zabbix]# systemctl list-unit-files | grep zabbix
zabbix-agent.service
enabled
6.查看日志方式
[root@host ~]#
tail -f /var/log/zabbix/zabbix_agentd.log
1097:20190621:011903.883 IPv6 support: YES
1097:20190621:011903.883 TLS support: YES
1097:20190621:011903.883 **************************
1097:20190621:011903.883 using configuration file: /etc/zabbix/zabbix_agentd.conf
1097:20190621:011903.884 agent #0 started [main process]
1111:20190621:011903.886 agent #1 started [collector]
1120:20190621:011903.886 agent #5 started [active checks #1]
1119:20190621:011903.887 agent #4 started [listener #3]
1113:20190621:011903.889 agent #2 started [listener #1]
1115:20190621:011903.891 agent #3 started [listener #2]
注:
如果有tommcat则需要将tomcat的logs文件夹加权限,不然获取不到log
chmod –R 755 /usr/local/installed/tomcat-8080/logs