首页 > 代码库 > zabbix API 删除host
zabbix API 删除host
脚本内容如下:
#!/usr/bin/python #-*- coding:utf8 -*- import json,sys,argparse from zabbix_api import ZabbixAPI server = "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") # 解析所传入的参数 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) print delete_host(host_id)
脚本使用:
# python host_delete.py --host=‘aaa,bbb‘ host delete success!
本文出自 “zengestudy” 博客,请务必保留此出处http://zengestudy.blog.51cto.com/1702365/1850655
zabbix API 删除host
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。