自动安装zabbix agent的shell脚本

#!/bin/bash

#install the zabbix agent

#Create by ShiYong

id zabbix &> /dev/null || useradd -s /sbin/nologin zabbix

mkdir /etc/zabbix /var/log/zabbix

chown zabbix.zabbix /var/log/zabbix/

tar zxf zabbix-2.0.12.tar.gz -C /usr/src/

cd /usr/src/zabbix-2.0.12/

./configure --prefix=/usr/local/zabbix/ --sysconfdir=/etc/zabbix/ --enable-agent &>/dev/null && make &>/dev/null && make install &> /dev/null

cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/

cd /etc/zabbix/

cp zabbix_agentd.conf zabbix_agentd.conf.origin

 

echo "modify the zabbix_agentd conf file"

sleep 1

read -p "input the zabbix server IP: " IP

 

#使用""引用变量IP

sed -i "/Server=127.0.0.1/ s/Server=127.0.0.1/Server=127.0.0.1,$IP/" /etc/zabbix/zabbix_agentd.conf

sed -i "/ServerActive=127.0.0.1/ s/ServerActive=127.0.0.1/ServerActive=$IP:10051/" /etc/zabbix/zabbix_agentd.conf

 

 

sed -i '/LogFile=\/tmp\/zabbix_agentd.log/ s@LogFile=/tmp/zabbix_agentd.log@LogFile=/var/log/zabbix/zabbix_agentd.log@' /etc/zabbix/zabbix_agentd.conf

 

sed -i '/# UnsafeUserParameters=0/ s/# UnsafeUserParameters=0/UnsafeUserParameters=1/' /etc/zabbix/zabbix_agentd.conf

echo "Include=/etc/zabbix/zabbix_agentd.conf.d/" >> /etc/zabbix/zabbix_agentd.conf

 

ln -s /usr/local/zabbix/sbin/zabbix_agentd /usr/local/sbin/

/etc/init.d/zabbix_agentd start

chkconfig zabbix_agentd on

 

echo "zabbix install finished"

转载于:https://www.cnblogs.com/gdlinux/p/6846366.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值