...
|
...
|
@@ -54,7 +54,7 @@ def rabbitmq_connect(): |
|
|
|
|
|
#连接influxdb
|
|
|
def influxdb_connect():
|
|
|
_influxdb = InfluxDBClient(Config.influxdb_host, Config.influxdb_port, timeout=1)
|
|
|
_influxdb = InfluxDBClient(Config.influxdb_host, Config.influxdb_port, timeout=Config.influxdb_timeout)
|
|
|
return _influxdb
|
|
|
|
|
|
#连接mongodb
|
...
|
...
|
@@ -92,22 +92,21 @@ def connect_close(): |
|
|
|
|
|
#数据入库定时器
|
|
|
def data_pull_timer(insert_data):
|
|
|
print time.time()
|
|
|
try:
|
|
|
for middleware,dbs in insert_data.items():
|
|
|
for db,measurements in dbs.items():
|
|
|
for measurement,queue in measurements.items():
|
|
|
try:
|
|
|
data_pull(queue,'Timer')
|
|
|
data_pull(queue)
|
|
|
except:
|
|
|
data_pull(queue,'Timer')
|
|
|
data_pull(queue)
|
|
|
except Exception as err:
|
|
|
print err
|
|
|
finally:
|
|
|
Timer(Config.multi_insert_timeout,data_pull_timer,[insert_data]).start()
|
|
|
|
|
|
#数据入库
|
|
|
def data_pull(queue,type = 'Normal'):
|
|
|
def data_pull(queue):
|
|
|
if queue.is_empty():
|
|
|
return
|
|
|
json_bodys = queue.get_all()
|
...
|
...
|
|