python - How get zabbix enabled host,Through the use of API -


this code,it can host.i need enabled host.

import requests import csv import json  url = 'https://xxxx.zabbix.com/api_jsonrpc.php' post_data = {     "jsonrpc": "2.0",     "method": "host.get",     "params": {         "filter":{             "with_monitored_items": true},         "output":             ["host"],         "selectinterfaces":             ["ip"]},     "id": 1,     "auth": "xxxxxxxxxxxxxxxxxx"}  post_header = {'content-type': 'application/json-rpc'}   ret = requests.post(url,                     data=json.dumps(post_data),                     headers=post_header,                     verify=false) data = ret.json()['result'] # print(data) parsed_result = [{'host': i['host'], 'eth0': i['interfaces'][0]['ip'],                   'type': 'vm', 'status': 'online'} in data] print(parsed_result) open("data.csv", "w") file:     csv_file = csv.writer(file)     header = ['hostname', 'eth0', 'type', 'status']     data_rows = [(i['host'], i['eth0'], i['type'], i['status']) in parsed_result]  # noqa     csv_file.writerow(header)     csv_file.writerows(data_rows) 

what should do?this zabbix doc: https://www.zabbix.com/documentation/3.0/manual/api/reference/host/get

i searching long time on net. no use. please or try give ideas how achieve this.

thanks in advance.

in host filter, add filtering status of 0, possibly so:

"filter":{         "with_monitored_items": true,         "status": "0"}, 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -