#!/bin/bash

ZBX_SERVER=172.16.20.248
Hostname=$1
ListenIP=$2

if [[ $# -ne 2 ]]
then
    echo "Usage: $(basename $0) Hostname ListenIP"
    exit 1
fi

rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm
yum -y install zabbix-agent --enablerepo=zabbix


sed -i "s/^Server=.*/Server=${ZBX_SERVER}/" /etc/zabbix/zabbix_agentd.conf
sed -i "s/^ServerActive=.*/ServerActive=${ZBX_SERVER}/" /etc/zabbix/zabbix_agentd.conf
sed -i "s/^Hostname=.*/Hostname=${Hostname}/" /etc/zabbix/zabbix_agentd.conf



sed -i "s/^# ListenIP=.*/ListenIP=${ListenIP}/" /etc/zabbix/zabbix_agentd.conf
sed -i "s/^# UnsafeUserParameters=.*/UnsafeUserParameters=1/" /etc/zabbix/zabbix_agentd.conf
curl -s -L -k https://shuhui:shuhui@down.vqiu.cn/conf/zabbix/diskIO/automonitordiskio.sh | bash -

systemctl restart zabbix-agent.service
systemctl enable zabbix-agent.service
