Skip to content

Instantly share code, notes, and snippets.

@otoolep
Last active December 20, 2016 01:07
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save otoolep/3d5741e680bf76021f77 to your computer and use it in GitHub Desktop.
Save otoolep/3d5741e680bf76021f77 to your computer and use it in GitHub Desktop.
Pump a sine way into a local influxdb cluster
#!/usr/bin/python
import json
import math
import requests
import sys
from time import sleep
DATABASE = 'test1'
STATUS_MOD = 10
n = 0
while True:
for d in range(0, 360):
v = [{'name': 'sin', 'columns': ['val'], 'points': [[math.sin(math.radians(d))]]}]
r = requests.post('http://localhost:8086/db/%s/series?u=root&p=root' % DATABASE, data=json.dumps(v))
if r.status_code != 200:
print 'Failed to add point to influxdb -- aborting.'
sys.exit(1)
n += 1
sleep(1)
if n % STATUS_MOD == 0:
print '%d points inserted.' % n
@otoolep
Copy link
Author

otoolep commented Dec 20, 2016

Thanks all -- yes, this code is quite old now and InfluxDB's protocols have moved on.

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