批量添加zabbix監控 1.使用ansible配置zabbix客戶端 ①修改服務器的IP(域名),爲了方便使用ansible來批量操作 等同於如下sed語句 sed -i 's#Server=1.1.1.11#Server=2.2.2.2#g' /usr/local/zabbix_agents_3.2.0/conf/zabbix_agentd.conf sed -i 's#ServerActive=1.1.1.11#ServerActive=2.2.2.2#g' /usr/local/zabbix_agents_3.2.0/conf/zabbix_agentd.conf 先使用一臺服務器測試,通過以後再批量操作即可 ②使用ansible將zabbix_agentd.conf的服務器IP有1.1.1.11更換爲2.2.2.2 ansible web01 -m replace -a 'path=/usr/local/zabbix_agents_3.2.0/conf/zabbix_agentd.conf regexp="1.1.1.11" replace="2.2.2.2"' ③重啓客戶端生效 ansible web01 -m shell -a "executable=/bin/bash /etc/init.d/zabbix_agentd restart" # 全部執行 ansible all -m replace -a 'path=/usr/local/zabbix_agents_3.2.0/conf/zabbix_agentd.conf regexp="1.1.1.11" replace="2.2.2.2"' ansible all -m shell -a "executable=/bin/bash /etc/init.d/zabbix_agentd restart" 因爲是內網所以不需要開啓防火牆放行這些IP 其他修改操作類似,就不繼續舉例說明了 2.服務端操作 ①整理agent端需要添加的模板、主機組等信息到excel中 ②不存在的模板需要添加到服務端templates中 ③執行zabbix_api批量操作excel添加監控 # 修改/etc/ansible/hosts加入如下主機(可以先通過excel整理後直接拷貝) frontend_web01 ansible_host=172.30.0.241 ansible_port=2018 ansible_user=root ansible_ssh_pass=pass frontend_web02 ansible_host=172.30.0.240 ansible_port=2018 ansible_user=root ansible_ssh_pass=pass backend_web1 ansible_host=172.30.0.245 ansible_port=2018 ansible_user=root ansible_ssh_pass=pass backend_web2 ansible_host=172.30.0.243 ansible_port=2018 ansible_user=root ansible_ssh_pass=pass backend_web3 ansible_host=172.30.0.242 ansible_port=2018 ansible_user=root ansible_ssh_pass=pass backend_web4 ansible_host=172.30.0.244 ansible_port=2018 ansible_user=root ansible_ssh_pass=pass # 測試ping命令報錯 [root@zabbix:~]# ansible eus_redis01 -m ping eus_redis01 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: command-line: line 0: Bad configuration option: stricthostkeychecking\\357\\274\\235no\r\n", "unreachable": true } 解決辦法: 修改ansible配置文件,關閉首次ssh檢查 # vim /etc/ansible/ansible.cfg # uncomment this to disable SSH key host checking host_key_checking = False
解決辦法: 修改ansible配置文件,關閉首次ssh檢查 # vim /etc/ansible/ansible.cfg # uncomment this to disable SSH key host checking host_key_checking = False
http://www.yuemei.com/u/86338687/
http://www.yuemei.com/u/86338693/
http://www.yuemei.com/u/86338699/
http://www.yuemei.com/u/86338711/
http://www.yuemei.com/u/86338717/
http://www.yuemei.com/u/86338720/
http://www.yuemei.com/u/86338777/
http://www.yuemei.com/u/86338786/
http://www.yuemei.com/u/86338792/
http://www.yuemei.com/u/86338801/
http://www.yuemei.com/u/86338810/
http://www.yuemei.com/u/86329906/
http://www.yuemei.com/u/86329951/
http://www.yuemei.com/u/86330011/
http://weheartit.com/1010921566
http://weheartit.com/5QkVAOpNOjUHk
http://weheartit.com/g5uarct3elfC
http://weheartit.com/UUVryii4I2Q9
http://weheartit.com/uYjLBGRUfWqD
http://weheartit.com/aZw6YzhCkW
http://weheartit.com/2f3tBV1uFlqo
http://weheartit.com/wmqKbzPPqoEm
http://weheartit.com/pJZa1ZRHfYyX
http://weheartit.com/IjwtMODUcYle
http://weheartit.com/uDi1LZLe7wNR
http://club.1688.com/article/63422384.html
http://club.1688.com/article/63412786.html
http://club.1688.com/article/63405672.html
http://club.1688.com/article/63374462.html
http://club.1688.com/article/63358014.html
http://club.1688.com/article/63353075.html