封装了python方位InfluxDB的类,代码如下:
# coding=utf-8
import time
import datetime
from influxdb import InfluxDBClient
class InfluxDBVisitor():
def __init__(self):
self.host = "XXX.XXX.XXX.XXX"
self.port = 8086
self.user = "influx"
self.password = "influx"
self.database = "test"
self.beginTime = datetime.datetime.now()
def Init(self):
self.client = InfluxDBClient(self.host, self.port, self.user, self.password, self.database) # 初始化
def InsertInput(self, dictInput):
# 插入数据
#data_list = [{'measurement': 'cpu',
# 'tags': {'host': '127.0.0.1'},
# 'fields': {'load': 0.5,
# 'usage': 0.