#!/bin/bash # datetime:2016-01-14 # Author:sckghost # Description:zabbix One-click installation script # Note: Because of the server more, so on the service side to build a wget software center, wget address can be customized # useing: can be installed directly on the client using the command Curl serverip/script/install_zabbix_agentd.sh | Sh
serverip=192.168.1.218#zabbix_server服务端IP version=zabbix-2.4.6#zabbix版本 Basedir=/usr/local/zabbix#zabbix安装目录 wget= ' wget-n-p/tmp http:/$ServerIP/download/$Version.tar.gz ' #软件中心下载
#1, open firewall port Iptables-i input-p tcp-m multiport--dport 10050:10051-j ACCEPT Service Iptables Save Service Iptables Restart Groupadd Zabbix Useradd zabbix-g Zabbix Ln-s $BASEDIR/sbin/*/usr/local/sbin/ Ln-s $BASEDIR/bin/*/usr/local/bin/
# 2, Zabbix installation Yum install-y gcc make autoconf gcc net-snmp-devel Curl curl-devel mysql-devel if [!-f/tmp/$Version. tar.gz] Then $wget Fi
Tar zxvf/tmp/$Version. TAR.GZ-C/tmp cd/tmp/$Version ./configure--prefix= $BASEDIR--enable-agent--with-net-snmp--with-libcurl Make && make install
#3, configuration zabbix_agentd.conf Sed-i ' s:# pidfile=/tmp/zabbix_agentd.pid:logfile= $BASEDIR/zabbix_agentd.pid:g ' $BASEDIR/etc/zabbix_agentd.conf Sed-i ' s#logfile=.*$ #LogFile = $BASEDIR/log/zabbix_agentd.log#g ' $BASEDIR/etc/zabbix_agentd.conf Sed-i ' s/^server=127.0.0.1/server= $ServerIP/g ' $BASEDIR/etc/zabbix_agentd.conf Sed-i ' s/^serveractive=127.0.0.1/serveractive= $ServerIP/g ' $BASEDIR/etc/zabbix_agentd.conf Sed-i ' s/# enableremotecommands=0/enableremotecommands=0/g ' $BASEDIR/etc/zabbix_agentd.conf Sed-i ' s/# logremotecommands=0/logremotecommands=0/g ' $BASEDIR/etc/zabbix_agentd.conf Sed-i ' s:# include=/usr/local/etc/zabbix_agentd.conf.d/*.conf:include= $BASEDIR/etc/zabbix_agentd.conf.d/*.conf:g ' $BASEDIR/etc/zabbix_agentd.conf Sed-i ' s/# unsafeuserparameters=0/unsafeuserparameters=1/g ' $BASEDIR/etc/zabbix_agentd.conf
#4, boot entry cp/tmp/$Version/misc/init.d/fedora/core/zabbix_agentd/etc/rc.d/init.d/zabbix_agentd Sed-i "s:basedir=/usr/local:basedir= $BASEDIR: G"/etc/rc.d/init.d/zabbix_agentd chmod +x/etc/rc.d/init.d/zabbix_agentd Chkconfig Zabbix_agentd on Killall Zabbix_agentd /etc/init.d/zabbix_agentd restart
|