[[Zabbix]]

*説明 [#w6eaed37]
対話式のインストールスクリプトです。

*スクリプトの内容 [#oe2b90af]
 #!/bin/bash
 
 ### Zabbix agent install check
 RPMCHK=`rpm -qa | grep zabbix-agent`
 
 if [ $? -eq 0 ];
    then
        echo "Zabbix agent is aleready installed."
        exit 10
 fi
 
 ### Zabbix install check
 MACHINEARC01=`uname -m`
 
 case ${MACHINEARC01} in
      x86_64 ) ARC01=x84_64 ;;
      i686 ) ARC01=i386 ;;
      i386 ) ARC01=i386 ;;
 esac
 
 cd /usr/local/src
 wget http://repo.zabbix.com/zabbix/2.2/rhel/6/${ARC01}/zabbix-2.2.7-1.el6.${ARC01}.rpm
 if [ $? -ne 0 ] ; then echo "[FAIL] It does not installed. bye.";exit ; fi
 
 wget http://repo.zabbix.com/zabbix/2.2/rhel/6/${ARC01}/zabbix-agent-2.2.7-1.el6.${ARC01}.rpm
 if [ $? -ne 0 ] ; then echo "[FAIL] It does not installed. bye.";exit ; fi
 
 rpm -ivh zabbix-*
 if [ $? -ne 0 ] ; then echo "[FAIL] It does not installed. bye.";exit ; fi
 chkconfig zabbix-agent on
 
 ### Zabbix agent conf var
 cd /etc/zabbix
 cp -p zabbix_agentd.conf zabbix_agentd.conf.original.`date +%Y%m%d`
 echo " "
 sleep 2
 echo -n "Type server IP address for zabbix check :"
 read LISTENIP
 sed -i "s/# ListenIP=0.0.0.0/ListenIP=${LISTENIP}/g" ./zabbix_agentd.conf
 #sed -i "s/# SourceIP=/SourceIP=${LISTENIP}/g" ./zabbix_agentd.conf
 
 #echo -n "Type server IP address for outgoing connections :"
 #read OUTIP
 #sed -i "s/# SourceIP=/SourceIP=${OUTIP}/g" ./zabbix_agentd.conf
 
 echo -n "Type Zabbix server IP address :"
 read ZABBIXIP
 sed -i "s/Server=127.0.0.1/Server=${ZABBIXIP}/g" ./zabbix_agentd.conf
 sed -i "s/ServerActive=127.0.0.1 /ServerActive=${ZABBIXIP}/g" ./zabbix_agentd.conf
 
 sed -i "s/Hostname=Zabbix server/Hostname=${HOSTNAME}/g" ./zabbix_agentd.conf
 sed -i "s/# Timeout=3/Timeout=10/g" ./zabbix_agentd.conf
 
 ### Zabbix start
 /etc/init.d/zabbix-agent start
 if [ $? -eq 0 ];then
    echo "[INFO] Zabbix agent start success!!"
 else
    echo "[FAIL] Zabbix agent start failed... bye.";exit
 fi
 
 ### Fire wall
 echo -n "Do you change iptables config?(y/n):"
 read IPTBL
 
 if [ ${IPTBL} = "y" ]; then
     cd /etc/sysconfig
     cp -p iptables iptables.`date +%Y%m%d`
     iptables -A INPUT -s ${ZABBIXIP}/32 -p tcp -j ACCEPT
     service iptables save
     if [ $? -eq 0 ]; then
        echo "[IFNO] iptables config change script success.";
     else
        echo "[FAIL] Please check iptables config file.";exit
     fi
 else
     echo "[INFO] iptables config does not chanege."
 fi
 
 echo "[INFO] Zabbix agent install script success!"
 
 exit 0

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS