#!/bin/bash

#建立账户
groupadd -g 1001 zabbix
useradd -u 1001 -g 1001 -s /sbin/nologin -M zabbix

#添加对应的yum源
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-agent-3.2.0-1.el6.x86_64.rpm

#安装
yum clean all
yum -y install zabbix-agent

#获取本机IP
HOST=ifconfig | grep Bcast | awk '{print $2}' | awk -F ":" '{print $2}'

#修改配置文件
sed -i 's/^Server=127.0.0.1/Server=192.168.1.1/g' /etc/zabbix/zabbix_agentd.conf
sed -i 's/^ServerActive=127.0.0.1/ServerActive=192.168.1.1/g' /etc/zabbix/zabbix_agentd.conf
sed -i 's/^Hostname=Zabbix server/Hostname=${HOST}/g' /etc/zabbix/zabbix_agentd.conf

#设为开机启动
service zabbix-agent start
chkconfig zabbix-agent on

#iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT
#service iptables save
#iptables restart

posted on 2018-08-20 15:45  彼时年少而无知  阅读(90)  评论(0)    收藏  举报