Creating hosts with the Zabbix API

Source: Internet
Author: User

#!/usr/bin/env python2.7# coding=utf-8from zabbix_api import zabbixapiimport  urllib2import sys## #get  visible_nameinet_ip=sys.argv[1]url =  ' http://10.47.102.185/api/ecs /?ip={0} '. Format (inet_ip) response = urllib2.urlopen (URL) result = response.read () info  = eval (result[1:-1]) visible_name = info[' name ']## #login  zabbixserver= "Http://ip/zabbix" Username= "zabbix_username" password= "password" Zapi = zabbixapi (server=server, path= "",  log_ level=0) Zapi.login (Username, password) # # #create  hosthost_name = sys.argv[2]if  Zapi.host.exists ({"Host": Host_name}):    print  ' host already exists ' else:     create_host=zapi.host.create ({"Host": Host_name, "groups": [{"GroupID": "8"}], "Interfaces" : [{"Type": "1", "Main": "1", "Useip": "1", "IP": inet_ip, "port": "10050", "DNS": ""}], "Templates": [{"TemplateID": "10001" }], "Inventory_mode":-1, "NAme ": Visible_name})     print create_host 


This article is from the "Zengestudy" blog, make sure to keep this source http://zengestudy.blog.51cto.com/1702365/1833902

Creating hosts with the Zabbix API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.