菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
357
0

isntall

原创
05/13 14:22
阅读数 53071
#! /bin/bash

# zabbix server address
zabbix='10.10.238.110'
# repo address
REPO='10.10.238.114:4507'

if [ -f /etc/yum.repos.d/sdata.repo ];then
    echo 'no operation'
else
    # check os version
    osmaster=`cat /etc/redhat-release |awk -F '.' '{print $1}' |awk '{print $NF}'`
    if [ $osmaster -eq 5 ];then
        # get repo config
        curl http://$REPO/repo/sdata5.repo -o /etc/yum.repos.d/sdata.repo
        # sudo file config
        echo '#includedir /etc/sudoers.d' >> /etc/sudoers
    else
        # get repo config
        curl http://$REPO/repo/sdata.repo -o /etc/yum.repos.d/sdata.repo
    fi
    # install zabbix agent
    yum --disablerepo=\* --enablerepo=sdata -y install zabbix-agent
    
    # check install status
    pkg=`rpm -qa zabbix-agent| wc -l`
    
    if [ $pkg -ge 1 ];then
        echo get zabbix config
        curl http://$REPO/repo/zabbix_config.tar.gz -o /tmp/zabbix_config.tar.gz
        # config
        tar xf /tmp/zabbix_config.tar.gz -C /
        # 
        sed -i 's/HOSTNAME/'`hostname`'/g' /etc/sdata/zabbix/zabbix_agentd.conf
        sed -i 's/SERVER/'$zabbix'/g' /etc/sdata/zabbix/zabbix_agentd.conf
        chown sdata: -R /etc/sdata
    
    
        if [ $osmaster -eq 7 ];then
            systemctl enable zabbix-agent
            systemctl start zabbix-agent
        else
            service zabbix-agent start
            chkconfig --add zabbix-agent
            chkconfig zabbix-agent on
        fi
       
        rm -f /tmp/zabbix_config.tar.gz
        rm -f /tmp/install.sh
    else
        echo 'zabbix-agent install failed'
    fi
fi

发表评论

0/200
357 点赞
0 评论
收藏