Zabbix API Delete Host

Source: Internet
Author: User

The script reads as follows:

#!/usr/bin/python#-*- coding:utf8 -*-import json,sys,argparsefrom zabbix_api import  ZabbixAPIserver =  "Http://172.16.206.128/zabbix" username =  "Admin" password =   "Zabbix" Zapi = zabbixapi (server=server, path= "",  log_level=0) Zapi.login (username,  password) Def get_args ():     parser = argparse. Argumentparser ()     parser.add_argument ("-H",  "--host",  help= "Host name")     #  parse the parameters passed in     args = parser.parse_args ()          if not args.host:         args.host = raw_input (' host:  ')     return args     DEF GET_HOST_ID (Host):     get_host_id = zapi.host.get (         {             "Output":  "HostID",              "Filter": {                  "Host": Host.split (",")              }        })      host_id = []    host_id.append ([i[' HostID '] for i in  GET_HOST_ID])     return host_id[0]    def delete_host ( HOSTS_ID):     hosts_delete = zapi.host.delete (hosts_id)      return  "Host delete success!"     if __name__ ==  "__main__":     args = get_ Args ()        host_id = get_host_id (args.host) &nbsP;   print delete_host (host_id) 


Script uses:

# python host_delete.py--host= ' aaa,bbb ' host delete success!


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

Zabbix API Delete Host

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.