1. 程式人生 > >Redis:zabbix自動發現監控多埠redis

Redis:zabbix自動發現監控多埠redis

待整理:

#!/usr/bin/env python
#encoding: utf-8 

import os
import json

base_dir = os.path.dirname(os.path.abspath(__file__))
port_file = os.path.join(base_dir,'redis.port')
print port_file

ports = []
try:
    with open(port_file,"r") as f:
        data = f.readlines()
        for i in data:
            ports += [{'{#REDISPORT}':i.strip()}]
except:
    f.close()

print json.dumps({'data':ports},sort_keys=True,indent=4,separators=(',', ':'))