17.解決zabbix host [Windows host] not found

 zabbix的服務器日誌會出現如下報錯:

  2389:20160223:113026.665 cannot send list of active checks to [10.0.5.10]: host [Windows host] not found


  出現這個問題的原因是因爲dashboard中顯示的hostname爲客戶端ip地址,而zabbix客戶端配置文件中的Hostname還是默認的“Windows host”,我們通過ansible調用python解決這個問題:


python代碼如下:

#!/usr/bin/python

import os
import time
import socket
import fileinput

os.system('sc stop "Zabbix Agent"')

time.sleep(10)

hostname = socket.gethostbyname(socket.gethostname())

for line in fileinput.input("C:\zabbix_agents_2.2.9.win\conf\zabbix_agentd.win.conf", inplace=1):
    line = line.replace("Hostname=Windows host", "Hostname=%s" % (hostname))
    print line,

os.system('sc start "Zabbix Agent"')


通過ansible進行批量修改:

ansible win -m script -a "/root/windows/zabbix_hostname.py"


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章