#!/bin/bash[ -d /usr/local/zabbix ] && echo "/usr/local/zabbix Exist " && exitif ps -ef | grep zabbix_agentd | grep -v grep ; thenecho "Zabbix agent is installed" exitfiyum install - Y autoconf automake imake libxml2-devel expat-devel cmake gcc gcc-c++ libaio libaio-devel bzr bison libtool ncurses5-devel net-snmp\* libxml2 libxml2-devel bzip2 libpng-devel freetype-devel bzip2-devel curl* curl-devel libjpeg\* openjpeg\*if [ $? != 0 ] ;thenecho -e " \033[31minstall rpm failed\033[0m "exit 0fiuseradd zabbixcd /tmpwget http:// 10.10.45.81:8000/zabbix-3.2.6.tar.gztar zvxf zabbix-3.2.6.tar.gzcd zabbix-3.2.6./configure --prefix=/usr/local/zabbiX --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2makemake installwhile truedoifconfigecho -e "\033[31mplease input network\033[0m" read inputif ifconfig $input >/dev/null ; thenip= ' ifconfig $input | grep "Inet addr" | awk ' {print $2} ' | awk -F ': ' ' {print $2} ' echo $ipbreakelseecho -e "\033[31minput err\033[0m" fidonesed -i ' s/ Server=127.0.0.1/server=10.10.45.152/g ' /usr/local/zabbix/etc/zabbix_agentd.confsed -i ' s/ Serveractive=127.0.0.1/serveractive=10.10.45.152/g ' /usr/local/zabbix/etc/zabbix_agentd.confsed -i "s/hostname=zabbix server/hostname= $ip/g" /usr/local/zabbix/etc/zabbix_agentd.confecho "- ------------------------------ show zabbix agent conf file --------------------- ----------"awk '/^[^#]/' /usr/local/zabbix/etc/zabbix_agentd.conf/usr/local/zabbix/sbin/zabbix_agentdif grep zabbix_ agentd /etc/rc.local >/dev/null ;thenecho -e "\033[31mno need change rc.local\033[0m "else echo "/usr/local/zabbix/sbin/zabbix_agentd " >> /etc/ Rc.localfi
Install Zabbix Agent shell script