zabbix-agent自动化脚本
作用:批量部署zabbix-agent。用于上百台虚拟机都可以被Zabbix监控。
脚本名:inst-agent.sh
#!/bin/bash
echo "-------getIP---------"
cat /etc/sysconfig/network-scripts/ifcfg-eth0 |grep IPADDR
a=`cat /etc/sysconfig/network-scripts/ifcfg-eth0 |grep IPADDR`
echo $a | awk -F'=' '{print$2}' >./tmp.log
IP=`cat tmp.log`
echo $IP
echo "------install_agent------"
rpm -Uvh https://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
yum install -y zabbix-agent
echo "------agent_conf----"
echo "PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=172.31.xxx.200
ListenPort= 10050
ServerActive=172.31.xxx.200
Hostname=${IP}
Include=/etc/zabbix/zabbix_agentd.d/" >/etc/zabbix/zabbix_agentd.conf
echo "----agent_auto_on--------"
/etc/init.d/zabbix-agent start
chkconfig --add zabbix-agent
chkconfig --level 35 zabbix-agent on
其中172.31.xxx.200
需要修改你Zabbix Server的IP地址。