Skip to content

Instantly share code, notes, and snippets.

@dragonxtek dragonxtek/ forked from ThomDietrich/
Last active Sep 29, 2016

What would you like to do?
Pump a sine way into a local influxdb cluster
import json
import math
import requests
import sys
from time import sleep
IP = ""
PORT = "8086"
DB = "test"
USER = "user"
PASSWORD = "password123"
TIME = 1
n = 0
while True:
for d in range(0, 360):
v = 'sine_wave value=%s' % math.sin(math.radians(d))
## without autentication
#r ="http://%s:8086/write?db=%s" %(IP, DB), data=v)
## with autentication
r ="http://%s:%s/write?db=%s" %(IP, PORT, DB), auth=(USER, PASSWORD), data=v)
if r.status_code != 204:
print 'Failed to add point to influxdb (%d) - aborting.' %r.status_code
n += 1
if n % STATUS_MOD == 0:
print '%d points inserted.' % n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.