zabbix-agent客户端配置文件与自定义监控脚本
批量配置zabbix_agentansible all -m apt -a "name=zabbix-agent"sed -i 's/^Server=127.0.0.1/Server=**你的zabbx-server的ip**/' /etc/zabbix/zabbix_agentd.confsed -i 's/^Hostname=Zabbix server/Hostname=$HOSTNAME/'
·
批量安装配置zabbix_agent
ansible all -m apt -a "name=zabbix-agent"
sed -i 's/^Server=127.0.0.1/Server=**你的zabbx-server的ip**/' /etc/zabbix/zabbix_agentd.conf
sed -i 's/^Hostname=Zabbix server/Hostname=$HOSTNAME/' /etc/zabbix/zabbix_agentd.conf
sed -i 's/^ServerActive=127.0.0.1/ServerActive=**你的zabbx-server的ip**/' /etc/zabbix/zabbix_agentd.conf
sed -i 's/^# RefreshActiveChecks=120/RefreshActiveChecks=120/' /etc/zabbix/zabbix_agentd.conf
systemctl restart zabbix-agent
批量自定义zabbix监控脚本
python环境
如果用shell脚本就不用安装
ansible all -m apt -a "name=python-pip"
ansible all -m shell -a "pip install client-sdk-python"
编辑脚本
vi /opt/***.py
#!/usr/bin/python3.6
****************
传脚本、加权限
如果不用ansible,就不用执行这一步
ansible all -m copy -a "src=你的脚本位置 dest=/etc/zabbix/"
ansible all -m shell -a "chmod +x /etc/zabbix/blockNumber.py"
修改配置文件
UserParameter=自定义的键值,你的脚本
#中间一定要用","隔开
#如果定义多个键值,再用这个格式添加再下一行即可
#键值的名称一定要和zabbix网页中配置的自定义监控项的键值名称一致
ansible platon -m lineinfile -a "dest=/etc/zabbix/zabbix_agentd.conf regexp='# UnsafeUserParameters=0' line='UnsafeUserParameters=1'"
ansible platon -m lineinfile -a "dest=/etc/zabbix/zabbix_agentd.conf regexp='# UserParameter=' line='UserParameter=*****,/etc/zabbix/*****.py'"
更多推荐
所有评论(0)