zbx.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:zbx 作者: karlesnine 项目源码 文件源码
def create_a_host(fqdn):
    """Create a host in zabbix server."""
    template_os_linux = get_template_id("Template OS Linux")
    if template_os_linux == "not found":
        click.echo('template not found in Zabbix : %s' % template_os_linux)
        sys.exit(0)
    else:
        dns_data = socket.gethostbyname_ex(fqdn)
        ip = dns_data[2][0]
        response = zapi.host.create(
            host=fqdn,
            interfaces={"type": 1, "main": 1, "useip": 0, "ip": ip, "dns": fqdn, "port": "10050"},
            groups={"groupid": "5"},
            templates={"templateid": template_os_linux}
        )
        click.echo('%s id %s is added with basic linux template' % (fqdn, response["hostids"][0]))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号