Skip to content

Instantly share code, notes, and snippets.

@t0mst0ne
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t0mst0ne/df8873d32c85924b28e2 to your computer and use it in GitHub Desktop.
Save t0mst0ne/df8873d32c85924b28e2 to your computer and use it in GitHub Desktop.
#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)
@t0mst0ne
Copy link
Author

grep -e "{" ~/mbox | grep -e "}" |grep -v "null" | sed 's/.* ({ .* }).*/\1/g' | python write_influxdb.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment