日志易自动安装Agent脚本(一)

由于我们的机器比较多,agent过期处理起来比较费劲,所以就写了个脚本自动安装

#!/bin/bash
#cd /home/osoper/ 
#wget  10.131.32.154:8000/heka-2_4_0.7-linux-386.tar.gz
mv /home/osoper/heka-2_4_0.7-linux-386.tar.gz  /opt/
#mv /root/heka-2_4_0.7-linux-386.tar.gz  /opt/
cd /opt/
chown root:root heka-2_4_0.7-linux-386.tar.gz
tar -xzvf heka-2_4_0.7-linux-386.tar.gz
chmod -R 755 heka-2_4_0.7-linux-386
cd heka-2_4_0.7-linux-386/bin/

sed -i "s/.*check-daemon.sh > \/dev\/null 2>&1$//g" /var/spool/cron/root

ip=$(ip addr|grep bond0|sed -nr 's#^.*inet(.*)/.* brd.*$#\1#gp')
if [ ! $ip ];then
    ip=$(ip addr|sed -nr 's#^.*inet(.*)/.* brd.*$#\1#gp')
fi

port=$(ss -anop|grep 10001)
if [ ! $port ];then
    port=10001
else
    port=10002
fi

/opt/heka-2_4_0.7-linux-386/bin/install.sh ${ip}:${port} 10.131.32.152:8080 ur token 10.131.32.152:5180

更新一下,处理了端口问题!

你可能感兴趣的:(运维)