Browse Source

修复BUG

master
xiaoz 7 years ago
parent
commit
3ce38965ca
  1. 30
      zabbix_agent.sh

30
zabbix_agent.sh

@ -11,20 +11,20 @@ osip=$(curl https://ip.awk.sh/api.php?data=ip)
zabbix_config="/etc/zabbix/zabbix_agentd.conf" zabbix_config="/etc/zabbix/zabbix_agentd.conf"
#配置zabbix agent #配置zabbix agent
function setting($hostname,$osip){ function setting(){
read -p "输入Zabbix server IP:" serverip read -p "输入Zabbix server IP:" serverip
#备份配置 #备份配置
cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.bak cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.bak
#设置Server name #设置Server name
sed -i "s/Hostname=Zabbix server/Hostname=${hostname}/g" ${zabbix_config} sed -i "s/Hostname=Zabbix server/Hostname=$1/g" ${zabbix_config}
#设置连接IP #设置连接IP
sed -i "s/# SourceIP=/SourceIP=${osip}/g" ${zabbix_config} sed -i "s/# SourceIP=/SourceIP=$2/g" ${zabbix_config}
#设置Server IP #设置Server IP
sed -i "s/ServerActive=127.0.0.1/ServerActive=${serverip}/g" ${zabbix_config} sed -i "s/Server=127.0.0.1/Server=${serverip}/g" ${zabbix_config}
echo "\n"
echo "##### 设置成功 #####" echo "##### 设置成功 #####"
echo "Server IP:${serverip}" echo "Server IP:${serverip}"
echo "Agent:${osip}:10050" echo "Agent:$2:10050"
echo "###############################" echo "###############################"
} }
@ -80,14 +80,22 @@ echo "q) 退出"
echo "----------------------------------" echo "----------------------------------"
read -p ":" num read -p ":" num
case $num in case $num in
1) 1)
centos7() #安装
setting($hostname,$osip) centos7
chk_firewall() #设置
setting $hostname $osip
#放行端口
chk_firewall
#启动服务
systemctl start zabbix-agent.service systemctl start zabbix-agent.service
;; ;;
2) 2)
echo "CentOS 6" centos6
setting $hostname $osip
#放行端口
chk_firewall
service zabbix-agent start
;; ;;
3) 3)
echo "Debian 8" echo "Debian 8"

Loading…
Cancel
Save