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]))
评论列表
文章目录