Last active
August 29, 2015 14:16
-
-
Save t0mst0ne/df8873d32c85924b28e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#from influxdb import InfluxDBClient | |
from influxdb.influxdb08 import InfluxDBClient | |
import fileinput | |
import json | |
import ast | |
client = InfluxDBClient('IP', 8086, 'ID', 'pw', 'twer') | |
for line in fileinput.input(): | |
line = line.replace('false','False').replace('true','True').replace('update_time','time').rstrip('\n') | |
line = ast.literal_eval(line) | |
line['time'] = int(line['time']) | |
print line | |
d = {} | |
points = [] | |
columns = [] | |
for k,v in line.items(): | |
points.append(v) | |
columns.append(k) | |
d['name'] = 'ER' | |
d['points'] = points | |
d['columns'] = columns | |
json_body = [{'points':[points], 'name':'ER', 'columns':columns}] | |
print json_body | |
client.write_points(json_body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
grep -e "{" ~/mbox | grep -e "}" |grep -v "null" | sed 's/.* ({ .* }).*/\1/g' | python write_influxdb.py