#!/bin/sh
#Create by mahenglong 2014.03.26
mkdir -p /data/logs
cd /usr/local
wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.2/zabbix-2.2.2.tar.gz
chmod -R 777 /data/logs
yum -y install net-snmp
yum -y install net-snmp-devel
BASE_DIR="/usr/local/"
TAR="zabbix-2.2.2.tar.gz"
tar -zxvf $BASE_DIR\/$TAR -C $BASE_DIR
cd $BASE_DIR\/zabbix-2.2.2
./configure --prefix=/usr/local/zabbix --enable-agent
make && make install
groupadd zabbix
useradd zabbix -g zabbix
ln -s /usr/local/zabbix/etc/zabbix_agentd.conf /etc/
cd /usr/local/zabbix-2.2.2/
\cp -rf misc/init.d/fedora/core/zabbix_agentd /etc/init.d/
chmod 700 /etc/init.d/zabbix_agentd
chown zabbix.zabbix /etc/init.d/zabbix_agentd
sed -i "s#Server=127.0.0.1#Server=114.112.95.50#" /etc/zabbix/zabbix_agentd.conf
sed -i "s#ServerActive=127.0.0.1#ServerActive=114.112.94.50#" /etc/zabbix/zabbix_agentd.conf
sed -i "/Hostname=/s#=.*#"=$HOSTNAME#"" /etc/zabbix/zabbix_agentd.conf
sed -i "s#\#/tmp/zabbix_agentd.pid#/data/logs/zabbix_agentd.pid#" /etc/zabbix/zabbix_agentd.conf
sed -i "s#/tmp/zabbix_agentd.log#/data/logs/zabbix_agentd.log#" /etc/zabbix/zabbix_agentd.conf
sed -i "s#\#Timeout=3#Timeout=30#" /etc/zabbix/zabbix_agentd.conf
cat>>/etc/services<<EOF
#Zabbix services
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trapper
EOF
/etc/init.d/zabbix_agentd start