centos7 zabbix安裝客戶端 -配置監控遠端主機
說明 147伺服器上安裝zabbix_service
要監控146伺服器,只需要在146伺服器上安裝zabbix_Agent 就可以了,
安裝 Agent
[[email protected] ~]# yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI // 解決 依賴
[[email protected] ~]# useradd -M -s /sbin/nologin zabbix
官網 https://www.zabbix.com/download_sources#tab:34
wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.14/zabbix-3.4.14.tar.gz
[[email protected] ~]# tar xvf zabbix-3.4.14.tar.gz
[[email protected] ~]# cd zabbix-3.4.14
[[email protected] zabbix]# ./configure --prefix=/usr/local/zabbix --enable-agent //被監控端只需要部署 agnet
只需要make install
[[email protected] zabbix]# make install
[[email protected] ~]# cat /etc/services|grep zabbix
zabbix-agent 10050/tcp # Zabbix Agent
zabbix-agent 10050/udp # Zabbix Agent
zabbix-trapper 10051/tcp # Zabbix Trapper
zabbix-trapper 10051/udp # Zabbix Trapper
啟動agent:
[[email protected] ~]# /usr/local/zabbix/sbin/zabbix_agentd
配置 Agnet 開機啟動
cp /usr/local/src/zabbix-3.4.14/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/ (複製啟動指令碼)
(拓展:core 和 core5 裡面的檔案都可以實現 zabbix 代理啟動,core 裡面是測試版本,core5 是穩定版本)
vim /etc/init.d/zabbix_agentd
ZABBIX_BIN="/usr/local/zabbix/sbin/zabbix_agentd" #修改此行
[[email protected] ~]# chkconfig --add zabbix_agentd
[[email protected] ~]# chkconfig zabbix_agentd on
配置 Agentd 的配置檔案#客戶端操作
vim /usr/local/zabbix/etc/zabbix_agentd.conf
(93行)Server=192.168.1.147 #zabbix server 地址,可以多個,用,隔開 填監控的主機
(134行)ServerActive=192.168.1.147 #主動檢查的意思,主動檢查主機的資料的資料傳送給 Zabbix Server
(145行)Hostname=146
(280行)UnsafeUserParameters=1
265行是新增監控模板的
啟動服務
[[email protected] ~]# /etc/init.d/zabbix_agentd restart
[[email protected] ~]# netstat -antup | grep zabbix
Server 端測試通訊
[[email protected] ~]# /usr/local/zabbix/bin/zabbix_get -s 192.168.1.146 -p10050 -k system.uname
Linux 146 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64
#可以獲取對方系統版本則證明沒有問題
客戶端這就配置好了,然後 在147上配置監控146就可以了
zabbix_agent.conf 是用超級服務(xinetd)的方式來啟動的,被動檢查,只有 Server 說檢查的時候才檢查
zabbix_agentd.conf 是以獨立程序的方式來啟動的,一般使用這個來做配置,自動檢查,自動提交 zabbix_server.conf Server 啟動配置檔案,只有一個
zabbix_get 是 Zabbix 中的一個程式,用於 Zabbix-Server 到 Zabbix-Agent 的資料獲取,通常可以用來 檢測驗證 Agent 的配置是否正確。它的使用方法如下
zabbix_get [-hV] -s <host name or IP> [-p <port>] [-I <IP address>] -k <key>
-h:遠端 Zabbix-Agent 的 IP 地址或者是主機名。
-p:遠端 Zabbix-Agent 的埠。
-I:本機出去的 IP 地址,用於一臺機器中有多個網絡卡的情況。
-k:獲取遠端 Zabbix-Agent 資料所使用的 Key。
[[email protected]~]# zabbix_get -s 192.168.1.64 -k system.uname
zabbix_sender 與 get 相反,用來發送 Zabbix 伺服器處理效能資料。該工具通常用於長時間執行的使用者腳 本,用於定期傳送可用性和效能資料。使用方法如下
zabbix_sender [-Vhv] {[-zpsI] -ko | [-zpI] -T -i <file> -r} [-c <file>]
引數說明:
-c --config <file> 配置檔案絕對路徑
-z --zabbix-server <server> zabbix server 的 IP 地址
-p --port <server port> zabbix server 埠.預設 10051
-s --host <hostname> 主機名,zabbix 裡面配置的主機名(不是伺服器的 hostname),不能使用
ip 地址
-I --source-address <IP address> 源 IP
-k --key <key> 監控項的 key
-o --value <key value> key 值
-i --input-file <input file> 從檔案裡面讀取 hostname、key、value 一行為一條資料,使用空格作為分
隔符,如果主機名帶空格,那麼請使用雙引號包起來
-T --with-timestamps 一行一條資料,空格作為分隔符: <hostname><key><timestamp>
<value>,配合 --input-file option,timestamp 為 unix 時間戳
-r --real-time 將資料實時提交給伺服器
-v --verbose 詳細模式, -vv 更詳細