Centos7 系统上zabbix-agent一键脚本

特别声明:此脚本只供本人线上使用,放到此博文方便自己查阅。网友切不可直接复制到自己的线上直接套用,使用前一定要多测试。如有套用使用造成损失,与本博主无关。

脚本使用说明:sh file eth0
sh install-zabbix-agent.sh etho
IP1为zabbix-server端的ip地址 192.168.68.40
$1指脚本外传的eth0网卡的参数

[root@localhost ~]# cat install-zabbix-agent.sh 
#/bin/bash
IP=$(/sbin/ifconfig $1 |awk 'NR==2{print $0}'|awk '{print $2}')
IP1=192.168.68.40
/usr/bin/wget -P /tmp http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-agent-3.2.1-1.el7.x86_64.rpm
/bin/rpm -ivh /tmp/zabbix-agent-3.2.1-1.el7.x86_64.rpm
systemctl enable zabbix-agent.service
#systemctl start zabbix-agent.service
sed -i "s/Server\=127.0.0.1/Server\=$IP1/g;s/ServerActive\=127.0.0.1/ServerActive\=$IP1/g;s/\# ListenIP\=0.0.0.0/ListenIP=${IP}/g;s/Hostname\=Zabbix server/Hostname\=${IP}/g;s/\# UnsafeUserParameters\=0/UnsafeUserParameters\=1/g" /etc/zabbix/zabbix_agentd.conf
systemctl restart zabbix-agent.service

猜你喜欢

转载自blog.51cto.com/wujianwei/2424166