-
Notifications
You must be signed in to change notification settings - Fork 2
/
influx.py
34 lines (31 loc) · 808 Bytes
/
influx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from influxdb import InfluxDBClient
from datetime import datetime
from monitor.stream import get_system_data
import json
DatabaseConfig = InfluxDBClient(
host="localhost",
port=8086,
username="chuck",
password="chuck",
database="stream",
ssl=False,
verify_ssl=False
)
data = get_system_data()
print("data received")
print(data)
#data = json.loads(data)
print("data loaded")
dbdata = [
{
"measurement": "status",
"time": datetime.now().isoformat(),
"fields": data,
"tags": {
"monitor": "system"
}
}
]
print("writing data prepared")
DatabaseConfig.write_points(dbdata)
print("data written")