zabbix_agent安装

#!/bin/bash
#by Charon2Pluto
#(linux)
ML=`df |awk '{print $2,$NF}'|sort -n|tail -1|awk '{print $2}'`

if [ "$ML" = "/ecapp" ]; then
ML=/ecapp/soft
fi

tar zxf zabbix-4.0.1.tar.gz

cd zabbix-4.0.1
./configure --prefix=$ML/zabbix_agent --enable-agent && make install

mkdir -p $ML/zabbix_agent/{logs,scripts}

cp $ML/zabbix_agent/etc/zabbix_agentd.conf $ML/zabbix_agent/etc/zabbix_agentd.conf.bak

Hostname=`hostname`

sed -i "/# PidFile=\/tmp\/zabbix_agentd.pid/a PidFile="$ML"\/zabbix_agent\/zabbix_agentd.pid" $ML/zabbix_agent/etc/zabbix_agentd.conf

sed -i "s@LogFile=/tmp/zabbix_agentd.log@LogFile="$ML"/zabbix_agent/logs/zabbix_agentd.log@" $ML/zabbix_agent/etc/zabbix_agentd.conf

sed -i 's|# StartAgents=3|StartAgents=0|' $ML/zabbix_agent/etc/zabbix_agentd.conf

sed -i 's|Server=127.0.0.1|Server=172.30.208.89|' $ML/zabbix_agent/etc/zabbix_agentd.conf

sed -i 's|ServerActive=127.0.0.1|ServerActive=172.30.208.89|' $ML/zabbix_agent/etc/zabbix_agentd.conf

sed -i "s|Hostname=Zabbix server|Hostname="$Hostname"|" $ML/zabbix_agent/etc/zabbix_agentd.conf

sed -i "/# Include=\/usr\/local\/etc\/zabbix_agentd.conf.d\/\*.conf/a Include="$ML"\/zabbix_agent\/etc\/zabbix_agentd.conf.d\/\*.conf" $ML/zabbix_agent/etc/zabbix_agentd.conf

grep -v "^#" $ML/zabbix_agent/etc/zabbix_agentd.conf

rm -rf $ML/zabbix-4.0.1
rm -rf $ML/zabbix-4.0.1.tar.gz
rm -rf $ML/zabbix.sh

猜你喜欢

转载自www.cnblogs.com/charon2/p/10349865.html