Zabbix LLD监控之创建发现的Python脚本
2016-06-20 18:56
330 查看
#!/usr/bin/python import requests,json ip_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_list result = json.dumps(data_json,sort_keys=True, indent=4) print result
上面的脚本是LLD监控的第一步 ==> 将监控对象做成Json格式。
下面是脚本的执行结果
{ "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" }, { "{#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" } ] }
本文出自 “zengestudy” 博客,请务必保留此出处http://zengestudy.blog.51cto.com/1702365/1791129
相关文章推荐
- python大数据工作流程
- python操作Excel读写--使用xlrd
- 安装numpy和matplotlib
- Python--内建函数
- 实例讲解Python的函数闭包使用中应注意的问题
- python之面向对象(一)
- Python中的数学运算操作符使用进阶
- 初心大陆-----python宝典 第四章
- Python for循环 基础知识篇(重要)
- python sorted()用法详解
- Python中在for循环中嵌套使用if和else语句的技巧
- Python入门简单的静态网页爬虫3.0 (爬虫的示例代码)
- python爬虫
- 基于python的测试框架behave----context
- Python问题集锦
- 使用C写Python的模块
- Python __init__ 构造函数生成对象时调用关系
- python3实现打印乘法口诀表
- 使用python jieba库进行中文分词
- Qr-Code encode and decode with python+qrcode+zbar