Zabbix LLD监控之创建发现的Python脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Zabbix LLD监控之创建发现的Python脚本相关的知识,希望对你有一定的参考价值。

#!/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

以上是关于Zabbix LLD监控之创建发现的Python脚本的主要内容,如果未能解决你的问题,请参考以下文章

zabbix低级自动发现之mysql多实例

Zabbix SNMP LLD实践(自动发现)

Zabbix实战-简易教程--低层次发现(LLD)

Zabbix lld发现磁盘监控

Zabbix通过MegaCli实现对LSI Raid卡硬盘监控(LLD)

Zabbix用好LLD,立马感觉高大上许多