centos6或7安装zabbix-agent
我们公司服务器监控使用的zabbix服务器,因为服务器太多,使用zabbix被动模式对zabbix服务器压力太大,所以需要安装zabbix-agent,写了一个比较简单的shell脚本,然后使用ansible可以很方便的在服务器安装部署一、获取shell变量#!/bin/bash###zabbix服务器地址zabbix_serverIP=10.10.1.74###zabbix agent地址###
·
我们公司服务器和网络设备监控状态使用的是zabbix,因为服务器太多,使用zabbix被动模式对zabbix服务器压力太大,所以客户端需要安装zabbix-agent,写了一个比较简单的shell脚本,然后使用ansible可以很方便的在服务器安装部署
一、获取shell变量
#!/bin/bash
###zabbix服务器地址
zabbix_serverIP=10.10.1.74
###zabbix agent地址
####注意这里的网卡是eth0,centos5/6/7/8网卡类型不一样,根据型号改变
HOSTNAME=`ip addr show eth0 | grep -w 'inet' | awk '{print $2}' | cut -d "/" -f 1`
二、导入zabbix-agent yum源,根据选择系统版本选择
#rhel7
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
#rhel6
#rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm
#rhel5
#rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/5/x86_64/zabbix-release-3.4-1.noarch.rpm
####通过yum安装zabbix-agent
yum install zabbix-agent -y
sed -i "s/Server=127.0.0.1/Server=$zabbix_serverIP/" /etc/zabbix/zabbix_agentd.conf
sed -i "s/ServerActive=127.0.0.1/Server=$zabbix_serverIP/" /etc/zabbix/zabbix_agentd.conf
sed -i "s/Hostname=Zabbix server/Hostname=$HOSTNAME/" /etc/zabbix/zabbix_agentd.conf
三、、启动agent服务并设置为开机自动启动
####在/etc/sysconfig/iptables 文件中加一列允许通过的规则放行zabbix-agent端口,我这开了iptables,未开通则注销
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10050 -j ACCEPT
#centos5/6开机启动
#chkconfig zabbix-agent on
#service zabbix-agent start
#centos7开机启动
systemctl restart zabbix-agent
systemctl enable zabbix-agent
更多推荐
所有评论(0)