zabbix服務端和客戶端只須要./zabbix_install.sh選擇安裝便可! 附上一個腳本和安裝包: 解包,運行zabbix_install.sh安裝 連接http://pan.baidu.com/s/1dFLqq7f 密碼:c7hi #!/bin/bash ##zabbix一鍵安裝 #定義變量 YUMNUM=`yum repolist 2>/dev/null|grep repolist: |sed 's/[^0-9]//g'` ZABBIXgz=zabbix-2.2.1.tar.gz ZABBIX=zabbix-2.2.1 phpbcmath=php-bcmath-5.3.3-22.el6.x86_64.rpm phpmbstring=php-mbstring-5.3.3-22.el6.x86_64.rpm #定義yum源是否可用腳本 YUMREPO (){ echo -ne "\033[34m正在檢測yum源\033[0m" sleep 3 if [ $YUMNUM -eq 0 ];then echo -e "\033[32myum源不可用,請先配置yum源\033[0m" exit 10 kill -9 $! sleep 2 else echo -e "\033[34myum源檢測經過!\033[0m" fi } #定義菜單 menu (){ echo " ##############----一鍵安裝菜單----##############" echo "# 1. 安裝zabbix 監控端" echo "# 2. 安裝agent被監控端" echo "# 3. 退出 " read -p "請輸入菜單【1-3】" select } #定義循環小鍵 WHILE(){ i=0 j=0.1 while : do i=`expr $i + 1` case $i in 1) echo -e '-'"\b\c" sleep $j ;; 2) echo -e '\\'"\b\c" sleep $j ;; 3) echo -e "|""\b\c" sleep $j ;; 4) echo -e "/""\b\c " sleep $j ;; *) i=0 ;; esac done } yilai_install (){ echo "----------正在安裝依賴包" case $select in 1) yum install -y gcc gcc-c++ make mysql-server mysql-devel libcurl-devel net-snmp-devel php php-ldap php-gd php-xml php-mysql php-mbstring php-bcmath httpd fping &>/dev/null ;; 2) yum install -y gcc* &>/dev/null ;; esac echo "----------依賴安裝完成" } #定義configure時是否出錯 configure_err(){ if [ $? -ne 0 ];then echo "cofigure失敗" kill -9 $! sleep 2 exit 11 fi } #定義make時是否出錯 make_err(){ if [ $? -ne 0 ];then echo "make失敗" kill -9 $! sleep 2 exit 12 fi } #定義make install 安裝時是否出錯 make_install_err(){ if [ $? -ne 0 ];then echo "make install失敗" kill -9 $! sleep 2 exit 13 fi } zabbix_install(){ YUMREPO yilai_install echo "-----------zabbix_server安裝中" useradd zabbix -s /sbin/nologin &>/dev/null /etc/init.d/mysqld start &>/dev/null mysql -e 'create database zabbix character set utf8;' mysql -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'" ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock rpm -ivh $phpmbstring --force --nodeps &>/dev/null rpm -ivh $phpbcmath --force --nodeps &>/dev/null tar zxf $ZABBIXgz &>/dev/null cd $ZABBIX ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl &>/dev/null configure_err make install &>/dev/null make_install_err echo "-----------安裝完成" sleep 3 echo "-----------正在導入zabbix數據庫" mysql zabbix /dev/null /etc/init.d/zabbix_agentd restart &>/dev/null /etc/init.d/httpd restart &>/dev/null } zabbix_agentd_install (){ YUMREPO yilai_install echo "-----------zabbix_agentd安裝中" useradd zabbix -s /sbin/nologin &>/dev/null tar zxf $ZABBIXgz &>/dev/null cd $ZABBIX ./configure --prefix=/usr/local/zabbix --enable-agent &>/dev/null configure_err make install &>/dev/null make_install_err echo "-----------安裝完成" 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 read -p "請輸入監控端ip :" ipip sed -i "81cServer=$ipip" /usr/local/zabbix/etc/zabbix_agentd.conf sed -i "122cServerActive=$ipip" /usr/local/zabbix/etc/zabbix_agentd.conf /etc/init.d/zabbix_agentd restart &>/dev/null chkconfig zabbix_agentd on echo -e "\033[32m安裝完成,按回車繼續\033[0m" read } while : do clear menu case $select in 1) WHILE zabbix_install kill -9 $! sleep 2 ;; 2) WHILE zabbix_agentd_install kill -9 $! sleep 2 ;; 3) exit 0 ;; *) echo "輸入有誤!" ;; esac done