码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2016-02-23 13:25:07      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:zabbix

 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"


本文出自 “11062687” 博客,请务必保留此出处http://11072687.blog.51cto.com/11062687/1744224

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

标签:zabbix

原文地址:http://11072687.blog.51cto.com/11062687/1744224

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!