zabbix agentd环境部署
Zabbix_Agentd环境部署[*]Zabbix Agentd部署
[*]Zabbix网页添加监控
系统环境
Zabbix_Client
# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
# uname -r
3.10.0-862.el7.x86_64
# hostname
Zabbix_Client_56.8
# ip a| grep 192.168.
inet 192.168.56.8/24 brd 192.168.56.255 scope global noprefixroute dynamic eth0
Zabbix Agentd部署
Zabbix下载
wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.0.0/zabbix-4.0.0.tar.gz
创建zabbix用户组
# groupadd zabbix
# useradd -g zabbix -s /sbin/nologin zabbix
解压编译安装
# tar xf zabbix-4.0.0.tar.gz
# cd zabbix-4.0.0
# yum install gcc-c++ -y
# ./configure --prefix=/usr/local/zabbix --enable-ipv6 --enable-agent
# make && make install
拷贝启动文件
# cp -rf misc/init.d/tru64/zabbix_agentd /etc/init.d/
# chmod +x /etc/init.d/zabbix_agentd
# vim /etc/init.d/zabbix_agentd
添加以下两行,修改最后一行的zabbix路径
#chkconfig:35 95 96
#description:Zabbix_agentd
DAEMON=/usr/local/zabbix/sbin/zabbix_agentd
修改Zabbix agentd配置文件
# cd /usr/local/zabbix/etc/
# grep -Ev "#|^$" zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log #日志路径
Server=192.168.56.7 #被动模式,Zabbix服务器主动来获取数据,该地址指向Zabbix Server地址
ServerActive=192.168.56.7 #主动模式,客户端主动向服务端提交数据,此地址也为zabbix Server地址
Hostname=192.168.56.8 #主机名称,一般写为IP地址
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf #外链文件
启动agentd
# /etc/init.d/zabbix_agentd start
Zabbix agent started.
# chkconfig zabbix_agentd on
####Zabbix 网页添加监控
网络测试
# systemctl stop iptables
# systemctl stop firewalld
# setenforce 0
# telnet 192.168.56.7 10051 #测速服务器的10051端口是否通讯
Trying 192.168.56.7...
Connected to 192.168.56.7.
Escape character is '^]'.
Zabbix Server get 数据测试
# zabbix_get --help
usage:
zabbix_get -s host-name-or-IP [-p port-number] [-I IP-address] -k item-key #语法
zabbix_get -h
zabbix_get -V
Get data from Zabbix agent.
General options:
-s --host host-name-or-IPSpecify host name or IP address of a host #-s指定agentd地址,可以是IP、主机名、域名等
-p --port port-number Specify port number of agent running on the host #指定get端口,默认是10050
(default: 10050)
-I --source-address IP-address Specify source IP address #指定源IP,为Server本机的地址,服务器如果有多ip的时候,你指定一个,一般都不指定
-k --key item-key Specify key of the item to retrieve value for #指定你想获取的键值key,有系统默认的key,你也可以自定
-h --help Display this help message
-V --version Display version number #版本
Example(s):
zabbix_get -s 127.0.0.1 -p 10050 -k "system.cpu.load" #示例,get本机的键值数据
实例:
# zabbix_get -k "system.cpu.load" -s 192.168.56.8 -p 10050
0.000000
# zabbix_get -k "system.hostname" -s 192.168.56.8 -p 10050
Zabbix_Client_56.8
# zabbix_get -k "agent.hostname" -s 192.168.56.8 -p 10050
192.168.56.8
添加主机监控
注意:为了便于新手学习,字体改为了中文
菜单栏上找到配置——》主机群组——》创建主机群组
然后找到配置——》主机——》创建主机
别急添加,再切换到模版页面,应用模版
再来切换到主机资产记录,资产记录简称(CMDB)
填写完之后,点击最下方的添加
想要看到我们监控的数据,可以到last data(最新数据)里面
页:
[1]