#!/usr/bin/pythonimport requests,jsonip_list=[]data_json={}url = ' Http://cmdb.cheyaoshicorp.com/api/ecs ' r = Requests.get (URL) ecss = Json.loads (r.text) for I in ecss:ip_dic={} host_ip = i.get (' IP ') ip_dic[' {#IP} ']=host_ip Ip_list.append (ip_dic) data_json[' data ']=ip_listresult = Json.dumps (data_json,sort_keys=true, indent=4) print result
The above script is the first step in LLD monitoring ==> the monitoring object into JSON format.
Here is the result of the script execution
{ "Data": [ { "{#IP}": "10.47.57.66" }, { "{#IP}": "10.47.102.185" }, { "{#IP}": "10.168.218.84" }, { "{#IP}": "10.46.77.142" }, { "{#IP}": "10.46.72.44 " }, { "{#IP}": "10.47.50.103" }, { "{#IP}": "10.46.73.48" }, { "{#IP}": "10.51.35.112" }, { "{#IP}": "10.47.49.170" }, { &nBSP; " {#IP} ": " 10.46.77.206 " }, { "{#IP}": "10.46.71.215" }, { "{#IP}": " 10.46.64.227 " }, { "{#IP}": " 10.174.33.182 " }, { "{#IP}": " 10.47.49.247 " }, { "{#IP}": "10.47.48.244"         }, { "{#IP}": "10.25.1.98" }, { "{#IP}": "10.117.51.126" }, { "{#IP}" : "10.47.50.246" }, { "{#IP}": " 10.173.232.173 " }, { "{#IP}": "10.47.89.96" }, { "{#IP}": "10.175.192.16" }, { "{#IP}": "10.173.232.156" }, { "{#IP}": "10.174.110.132" }, { "{#IP}": "10.173.161.220"         }, { "{#IP}": " 10.174.107.151 " }, { "{#IP}": " 10.46.75.201 " }, { "{#IP}": " 10.46.68.71 " }, { "{#IP}": "10.47.107.82" }, { "{#IP}": "10.47.75.182" }, { "{#IP}": "10.46.77.227" }, { "{#IP}" : "10.46.76.37" }, { "{#IP}": " 10.45.23.211 " }, { "{#IP}": " 10.47.106.145 " }, { "{#IP}": "10.47.98.9 " }, { "{#IP}": "10.47.91.172"         }, { "{#IP}": "10.46.73.241" }, { "{#IP}": "10.46.73.8" }, { "{#IP}" : "10.46.69.177"         }    ]}
This article is from the "Zengestudy" blog, make sure to keep this source http://zengestudy.blog.51cto.com/1702365/1791129
Zabbix LLD Monitoring the creation of Python scripts found