#!/bin/bash
#关闭selinux & firewall
setenforce 0
service iptables stop
#添加zabbix账户
groupadd zabbix;useradd -g zabbix -r zabbix
#获取源代码
cd /usr/local/src;wget --no-check-certificate http://IP:PORT/zabbix.tar.gz
tar -zxf zabbix.tar.gz
#编译安装
cd /usr/local/src/zabbix;./configure --prefix=/usr/local/zabbix/ --enable-agent
make;make install
#启动脚本
cp /usr/local/src/zabbix/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
sed -i 's#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#' /etc/init.d/zabbix_agentd
chkconfig --add zabbix_agentd
chkconfig --level 2345 zabbix_agentd on
#配置
ipaddr=`ifconfig eth0|awk '/inet addr:/ {print $2}'|awk -F: '{print $2}'`
sed -i 's/Server=127.0.0.1/Server=Zabbix Server IP/' /usr/local/zabbix/etc/zabbix_agentd.conf
sed -i "s/Hostname=Zabbix server/Hostname=$ipaddr/" /usr/local/zabbix/etc/zabbix_agentd.conf
sed -i 's/# UnsafeUserParameters=0/UnsafeUserParameters=1/' /usr/local/zabbix/etc/zabbix_agentd.conf
#启动
service zabbix_agentd start
网友评论