目錄
1、 配置zabbix的yum源
2、下載下傳zabbix-agent
3、配置zabbix-agent的配置檔案
4、關閉防火牆,selinux
5、重新開機zabbix-agent
6、連通性測試,在zabbix-server伺服器上面使用zabbix_get擷取zabbix-agent伺服器上的資料
7、在zabbix web端配置zabbix-agent所在的主機
1、添加主機
2、添加監控項
3、添加圖形
4、再添加一個可用記憶體的監控項
5、根據建立的監控項建立一個觸發器
8、為主機添加zabbix模闆
我們已經在zabbix伺服器上面部署了zabbix server,也成功監控了zabbix server本機上的一些資料,現在通過部署zabbix-agent來監控别的主機
1、 配置zabbix的yum源
rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
執行結果:
[[email protected] yum.repos.d]# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
擷取http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.msuGpK: 頭V4 RSA/SHA512 Signature, 密鑰 ID a14fe591: NOKEY
準備中... ################################# [100%]
正在更新/安裝...
1:zabbix-release-4.0-1.el7 ################################# [100%]
[[email protected] yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo zabbix.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo CentOS-x86_64-kernel.repo
#########################################################################
2、下載下傳zabbix-agent
yum install zabbix-agent -y
執行結果:
[[email protected] yum.repos.d]# yum install zabbix-agent -y
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.bupt.edu.cn
* extras: mirrors.bupt.edu.cn
* updates: mirrors.bfsu.edu.cn
zabbix | 2.9 kB 00:00:00
zabbix-non-supported | 2.9 kB 00:00:00
zabbix-non-supported/x86_64/pr FAILED ] 21 kB/s | 117 kB 00:00:09 ETA
http://repo.zabbix.com/non-supported/rhel/7/x86_64/repodata/4ff39c776cba1953bdc6df66cdcc08ff9b7613aeb3bb9ef006a45c635189902c-primary.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: repo.zabbix.com; Unknown error"
正在嘗試其它鏡像。
(1/2): zabbix/x86_64/primary_db | 302 kB 00:00:13
zabbix-non-supported/x86_64/primary_db | 3.7 kB 00:00:00
正在解決依賴關系
--> 正在檢查事務
---> 軟體包 zabbix-agent.x86_64.0.4.0.44-1.el7 将被 安裝
--> 解決依賴關系完成
依賴關系解決
========================================================================================================================
Package 架構 版本 源 大小
========================================================================================================================
正在安裝:
zabbix-agent x86_64 4.0.44-1.el7 zabbix 431 k
事務概要
========================================================================================================================
安裝 1 軟體包
總下載下傳量:431 k
安裝大小:1.7 M
Downloading packages:
警告:/var/cache/yum/x86_64/7/zabbix/packages/zabbix-agent-4.0.44-1.el7.x86_64.rpm: 頭V4 RSA/SHA512 Signature, 密鑰 ID a14fe591: NOKEY
zabbix-agent-4.0.44-1.el7.x86_64.rpm 的公鑰尚未安裝
zabbix-agent-4.0.44-1.el7.x86_64.rpm | 431 kB 00:00:03
從 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 檢索密鑰
導入 GPG key 0xA14FE591:
使用者ID : "Zabbix LLC <[email protected]>"
指紋 : a184 8f53 52d0 22b9 471d 83d0 082a b56b a14f e591
軟體包 : zabbix-release-4.0-1.el7.noarch (installed)
來自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 資料庫已被非 yum 程式修改。
正在安裝 : zabbix-agent-4.0.44-1.el7.x86_64 1/1
驗證中 : zabbix-agent-4.0.44-1.el7.x86_64 1/1
已安裝:
zabbix-agent.x86_64 0:4.0.44-1.el7
完畢!
#########################################################################
3、配置zabbix-agent的配置檔案
[[email protected] zabbix]# cat /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
# 日志級别
DebugLevel=3
LogFileSize=0
# zabbix-server的位址
Server=192.168.20.10
ListenPort=10050
# 監聽的機器ip
ListenIP=192.168.20.11
ServerActive=192.168.20.10
Hostname=192.168.20.11
Include=/etc/zabbix/zabbix_agentd.d/*.conf
#########################################################################
4、關閉防火牆,selinux
[[email protected] zabbix]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[[email protected] zabbix]# service firewalld stop
Redirecting to /bin/systemctl stop firewalld.service
[[email protected] zabbix]# setenforce 0
#########################################################################
5、重新開機zabbix-agent
[[email protected] zabbix]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[[email protected] zabbix]# systemctl start zabbix-agent
[[email protected] zabbix]# ps -ef | grep zabbix
zabbix 2087 1 0 14:46 ? 00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 2088 2087 0 14:46 ? 00:00:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 2089 2087 0 14:46 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 2090 2087 0 14:46 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 2091 2087 0 14:46 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 2092 2087 0 14:46 ? 00:00:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 2131 1979 0 14:48 pts/0 00:00:00 grep --color=auto zabbix
#########################################################################
6、連通性測試,在zabbix-server伺服器上面使用zabbix_get擷取zabbix-agent伺服器上的資料
[[email protected] zabbix]# /usr/bin/zabbix_get -s 192.168.20.11 -p 10050 -k "system.cpu.load[all,avg1]"
0.000000
[[email protected] zabbix]# /usr/bin/zabbix_get -s 192.168.20.11 -p 10050 -k "system.hostname"
zabbix-agent
[[email protected] zabbix]# /usr/bin/zabbix_get -s 192.168.20.11 -p 10050 -k "system.uname"
Linux zabbix-agent 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64
#########################################################################
7、在zabbix web端配置zabbix-agent所在的主機
1、添加主機
可以看到,添加主機成功
#########################################################################
2、添加監控項
#########################################################################
3、添加圖形
檢視剛才建立的圖形
還可以選擇繪圖風格
#########################################################################
4、再添加一個可用記憶體的監控項
添加監控項可以按照模闆上的名字來起
将建立的可用記憶體也添加到圖形裡面
再次檢視圖形,可以看到,memory這個應用集就有兩個監控項圖形了。
#########################################################################
5、根據建立的監控項建立一個觸發器
觸發器設定完成
#########################################################################
8、為主機添加zabbix模闆
選擇好模闆以後,update更新
可以看到,應用了模闆的主機會多了許多的應用集applications,監控項items,觸發器triggers,圖形graphs,等等
再檢視 Monitoring --》graphs 可以看到,多了很多圖形,使用模闆,一鍵擷取監控資料圖形,非常友善。