-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstore.py
More file actions
24 lines (22 loc) · 808 Bytes
/
store.py
File metadata and controls
24 lines (22 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from influxdb import InfluxDBClient
from influxdb.client import InfluxDBClientError
class InfluxWriter(object):
def __init__(self):
self.client = InfluxDBClient(
"influxsrv.hyperpilot", 8086, "root", "root", "be_controller")
try:
self.client.create_database("be_controller")
except InfluxDBClientError:
pass #Ignore
def write(self, time, hostname, controller, data):
try:
self.client.write_points([{
"time": time,
"tags": {
"hostname": hostname,
},
"measurement": controller,
"fields": data,
}])
except InfluxDBClientError as e:
print("Store:ERROR: Error writing to influx: " + str(e))