Last active
December 20, 2016 01:07
-
-
Save otoolep/3d5741e680bf76021f77 to your computer and use it in GitHub Desktop.
Pump a sine way into a local influxdb cluster
This file contains hidden or 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
#!/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 |
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
Updated fork https://gist.github.com/ThomDietrich/ff836dbe0f0eaa2c5270a846a963893b