1
0
Fork 0
mirror of https://github.com/Luzifer/mqtt2influx.git synced 2024-10-18 05:44:19 +00:00
mqtt2influx/influx.py

38 lines
998 B
Python
Raw Permalink Normal View History

2020-07-11 16:20:49 +00:00
from influxdb import InfluxDBClient
class Influx():
def __init__(self, host, port, user, password, database):
self.client = InfluxDBClient(
host=host,
port=port,
username=user,
password=password,
database=database,
ssl=True,
verify_ssl=True,
)
2020-07-11 16:20:49 +00:00
self.database = database
def submit(self, body):
"""
submit("mydatabase", [
{
"measurement": "cpu_load_short",
"tags": {
"host": "server01",
"region": "us-west"
},
"time": "2009-11-10T23:00:00Z",
"fields": {
"Float_value": 0.64,
"Int_value": 3,
"String_value": "Text",
"Bool_value": True
}
}
])
"""
self.client.write_points(body, database=self.database)