解决zabbix host [Windows host] not found
zabbix的服务器日志会出现如下报错:1
2389:20160223:113026.665 cannot send list of active checks to : host not found
出现这个问题的原因是因为dashboard中显示的hostname为客户端ip地址,而zabbix客户端配置文件中的Hostname还是默认的“Windows host”,我们通过ansible调用python解决这个问题:
python代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/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进行批量修改:
1
ansible win -m script -a "/root/windows/zabbix_hostname.py"
页:
[1]