#!/bin/bash #wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.3/zabbix-2.2.3.tar.gz tar zxf zabbix-2.2.3.tar.gz cd zabbix-2.2.3 ./configure --prefix=/usr/local/zabbix --enable-agent make install #執行完上面命令,在/usr/local/sbin目錄下會生成zabbix_agent、zabbix_agentd、zabbix_get、zabbix_sender四個檔。 mkdir /etc/zabbix #追加zabbix agentd用戶 groupadd zabbix ;useradd -g zabbix -s /sbin/nologin zabbix #設定檔和啟動腳本 #mkdir /etc/zabbix #vim /usr/local/zabbix/etc/zabbix_agentd.conf #設定/usr/local/zabbix/etc/zabbix_agentd.conf檔,修改下面幾個地方: sed -i 's/^Server=127.0.0.1/Server=192.168.85.225/g' /usr/local/zabbix/etc/zabbix_agentd.conf #Server=127.0.0.1 ← ZABBIX伺服器的IP地址 #sed -i 's/^Hostname=Zabbix server/Hostname=/g' /usr/local/zabbix/etc/zabbix_agentd.conf #Hostname=localhost ← ZABBIX agentd的host名字 #ListenIP=127.0.0.1 ← ListenIP位址(要與監視物件伺服器上設定的一樣) #PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log #新建zabbix的pid檔和log檔的目錄 #mkdir /var/run/zabbix #mkdir /var/log/zabbix #chown zabbix:zabbix /var/run/zabbix #chown zabbix:zabbix /var/log/zabbix #啟動腳本設定 cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/ sed -i "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" /etc/init.d/zabbix_agentd ln -s /usr/local/zabbix/etc /etc/zabbix ln -s /usr/local/zabbix/bin/* /usr/bin/ ln -s /usr/local/zabbix/sbin/* /usr/sbin/ cat >> /etc/services <<end zabbix-agent 10050/tcp #Zabbix Agent zabbix-agent 10050/udp #Zabbix Agent zabbix-trapper 10051/tcp #Zabbix Trapper zabbix-trapper 10051/udp #Zabbix Trappe end #賦予啟動腳本許可權 chmod 755 /etc/init.d/zabbix_agentd #啟動 sed -i 's/^Hostname=Zabbix server/Hostname=192.168.85.222/g' /usr/local/zabbix/etc/zabbix_agentd.conf /etc/init.d/zabbix_agentd start #設置該啟動腳本為守候service chkconfig zabbix_agentd on #OK