dict[host] = ip return dict # 排序ip列表 def getData(dict): data = dict ip_list = [] for key in data.keys(): ip = data[key] ip_list.append(ip) ip_list = list(set(ip_list)) ip_list.sort() return ip_list # 整理输出ip def getGroup(ip_list): ip_group = {} ips = ip_...
jsonrpc=>'2.0',method=>'host.get',params=>{"output"=> ['name',"host"],#可以进行模糊匹配"selectInterfaces"=> ["interfaces","ip"]#过滤 ip},id=>1,auth=>"$authID",};my$response=$client->call($url,$json);die"host.get failed\n"unless$response->content->{result};my$hostID;forea...
获取zabbix 所有的hostip from login import * #定义模糊获取主机ip信息的函数 def getHostsip(url,auth): hostsip=[] values = {'jsonrpc': '2.0', 'method': 'host.get', 'params': { 'output': [ "hostid"], 'selectInterfaces': [ "ip" ], }, 'auth': auth, 'id': '10' } output ...
"jsonrpc" : "2.0", "method" : "host.get", "params" : { 'output' : [ 'hostid', 'name' ], }, "auth" : auth['result'], "id" : 2, } res2 = requests.post(url, data=json.dumps(payload), headers=headers) res2 = res2.json() for host in res2['result'] : with open(...
有了上述参数,便可以采用host.create方法创建一个主机,参考手册方法(https://www.zabbix.com/documentation/6.0/zh/manual/api/reference/host/create)。对IP地址为192.168.217.140,端口为10050的主机进行监控,名称为CentOS_7,监控模板:Linux by Zabbix Agent,群组:Linux servers。#创建监控主机,输入host_...
"method": "host.get", "params": { "output": ["name", "interfaces"], "groupids": group_id, "filter": { "status": "0" }, "selectInterfaces": ["ip"], }, "id": 1, "auth": auth } response = requests.post(url=ApiUrl, headers=header, json=data) ...
"method": "host.get", "params": { "output": [ "hostid", "host" ], "selectInterfaces": [ "interfaceid", "ip" ] }, "id": 1, "auth": self.user_login(), #这是第一步获取的身份验证令牌 } response = requests.post(self.url, data = json.dumps(post_data), headers = self.hea...
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")parser.add_argument("-i","--ip",help...
检索问题:使用获取到的API访问令牌,可以发送POST请求到Zabbix API的problem.get方法来检索问题。可以通过设置不同的过滤条件来获取特定的问题列表。常用的过滤条件包括问题的状态、问题的级别、问题的主机等。 检索主机名:同样使用获取到的API访问令牌,可以发送POST请求到Zabbix API的host.get方法来检索主机名。可以...
http://127.0.0.1/zabbix/api_jsonrpc.php (2)使用sessionid请求来调用API的host.get方法,命令如下: shell# curl -X POST \ -H 'Content-Type: application/json' \ -d '{"jsonrpc":"2.0", "method":"host.get", "params":{ "output":"extend", ...