監控伺服器就位後,每台被監控主機都需要裝上 agent。以下以 Zabbix 2.2.10 為例。
[root@localhost ~]# yum install -y gcc make [root@localhost ~]# cd /usr/local/src [root@localhost ~]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.10/zabbix-2.2.10.tar.gz [root@localhost src]# tar zxvf zabbix-2.2.10.tar.gz [root@localhost zabbix-2.2.10]# ./configure --prefix=/usr/local/zabbix --enable-agent [root@localhost zabbix-2.2.10]# make install
[root@localhost zabbix-2.2.10]# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/ [root@localhost ~]# ln -s /usr/local/zabbix/etc /etc/zabbix [root@localhost ~]# ln -s /usr/local/zabbix/sbin/zabbix_agentd /usr/local/sbin/
[root@localhost ~]# cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf-$(date +%Y%m%d) [root@localhost ~]# vi /etc/zabbix/zabbix_agentd.conf PidFile=/tmp/zabbix_agentd.pid LogFile=/tmp/zabbix_agentd.log EnableRemoteCommands=1 Server=192.168.55.132 ServerActive=192.168.55.132 Hostname=Zabbix server UnsafeUserParameters=1
重點:Server 與 ServerActive 必須填 Zabbix Server 的 IP;Hostname 要與 Web 介面上新增主機時填的名稱一致,否則資料對不上。
[root@localhost ~]# /etc/init.d/zabbix_agentd start
記得放通伺服器端的 10050/tcp,並在 Web 介面新增主機;若 EnableRemoteCommands 與 UnsafeUserParameters 非必要,建議保持關閉以減少風險。
