Zabbix_Agentd環境部署
- Zabbix Agentd部署
- Zabbix網頁添加監控
系統環境
Zabbix_Client
[root@Zabbix_Client_56 ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@Zabbix_Client_56 ~]# uname -r
3.10.0-862.el7.x86_64
[root@Zabbix_Client_56 ~]# hostname
Zabbix_Client_56.8
[root@Zabbix_Client_56 ~]# 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用戶組
[root@Zabbix_Client_56 zabbix-4.0.0]# groupadd zabbix
[root@Zabbix_Client_56 zabbix-4.0.0]# useradd -g zabbix -s /sbin/nologin zabbix
解壓編譯安裝
[root@Zabbix_Client_56 src]# tar xf zabbix-4.0.0.tar.gz
[root@Zabbix_Client_56 src]# cd zabbix-4.0.0
[root@Zabbix_Client_56 zabbix-4.0.0]# yum install gcc-c++ -y
[root@Zabbix_Client_56 zabbix-4.0.0]# ./configure --prefix=/usr/local/zabbix --enable-ipv6 --enable-agent
[root@Zabbix_Client_56 zabbix-4.0.0]# make && make install
拷貝啓動文件
[root@Zabbix_Client_56 zabbix-4.0.0]# cp -rf misc/init.d/tru64/zabbix_agentd /etc/init.d/
[root@Zabbix_Client_56 zabbix-4.0.0]# chmod +x /etc/init.d/zabbix_agentd
[root@Zabbix_Client_56 zabbix-4.0.0]# vim /etc/init.d/zabbix_agentd
添加以下兩行,修改最後一行的zabbix路徑
#chkconfig:35 95 96
#description:Zabbix_agentd
DAEMON=/usr/local/zabbix/sbin/zabbix_agentd
修改Zabbix agentd配置文件
[root@Zabbix_Client_56 zabbix-4.0.0]# cd /usr/local/zabbix/etc/
[root@Zabbix_Client_56 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
[root@Zabbix_Client_56 etc]# /etc/init.d/zabbix_agentd start
Zabbix agent started.
[root@Zabbix_Client_56 etc]# chkconfig zabbix_agentd on
####Zabbix 網頁添加監控
網絡測試
[root@Zabbix_Client_56 etc]# systemctl stop iptables
[root@Zabbix_Client_56 etc]# systemctl stop firewalld
[root@Zabbix_Client_56 etc]# setenforce 0
[root@Zabbix_Client_56 etc]# telnet 192.168.56.7 10051 #測速服務器的10051端口是否通訊
Trying 192.168.56.7...
Connected to 192.168.56.7.
Escape character is '^]'.
Zabbix Server get 數據測試
[root@Zabbix_Server_56 html]# 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-IP Specify 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[all,avg1]" #示例,get本機的鍵值數據
實例:
[root@Zabbix_Server_56 html]# zabbix_get -k "system.cpu.load[all]" -s 192.168.56.8 -p 10050
0.000000
[root@Zabbix_Server_56 html]# zabbix_get -k "system.hostname" -s 192.168.56.8 -p 10050
Zabbix_Client_56.8
[root@Zabbix_Server_56 html]# zabbix_get -k "agent.hostname" -s 192.168.56.8 -p 10050
192.168.56.8
添加主機監控
注意:爲了便於新手學習,字體改爲了中文
菜單欄上找到配置——》主機羣組——》創建主機羣組
然後找到配置——》主機——》創建主機
別急添加,再切換到模版頁面,應用模版
再來切換到主機資產記錄,資產記錄簡稱(CMDB)
填寫完之後,點擊最下方的添加
想要看到我們監控的數據,可以到last data(最新數據)裏面