希望的效果 :
{
"data": [
{
"{#SITEURL}": "127.0.0.1,code,port",
"{#SITEPORT}": "9931"
}
]
实际的效果:
{
"data": [
{
"{#SITEURL}": "127.0.0.1,code,port"
},
{
"{#SITEPORT}": "9931"
}
]
脚本 :
#!/usr/bin/env python
#encoding=utf8
import os
import json
active_url = file('/etc/zabbix/script/discovery/active_url.txt')
active_port = file('/etc/zabbix/script/discovery/active_port.txt')
d01 = []
for url in active_url.readlines():
for port in active_port.readlines():
d01.append({"{#SITEURL}": url.strip()}),
d01.append({"{#SITEPORT}": port.strip()})
print json.dumps({'data': d01},{'data': d01}, sort_keys=True, indent=4, separators=(',', ': '))
{
"data": [
{
"{#SITEURL}": "127.0.0.1,code,port",
"{#SITEPORT}": "9931"
}
]
实际的效果:
{
"data": [
{
"{#SITEURL}": "127.0.0.1,code,port"
},
{
"{#SITEPORT}": "9931"
}
]
脚本 :
#!/usr/bin/env python
#encoding=utf8
import os
import json
active_url = file('/etc/zabbix/script/discovery/active_url.txt')
active_port = file('/etc/zabbix/script/discovery/active_port.txt')
d01 = []
for url in active_url.readlines():
for port in active_port.readlines():
d01.append({"{#SITEURL}": url.strip()}),
d01.append({"{#SITEPORT}": port.strip()})
print json.dumps({'data': d01},{'data': d01}, sort_keys=True, indent=4, separators=(',', ': '))