Last active
August 29, 2015 14:06
-
-
Save mr337/baf4c36039a896df490a to your computer and use it in GitHub Desktop.
Import test data into openTSD
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
import urllib | |
import urllib2 | |
import json | |
import time | |
from random import randint | |
#microsecond precision must be in 13 digit format, no period | |
t_old = '{:0<13}'.format(''.join(str(time.time()).split('.'))) | |
while True: | |
t = '{:0<13}'.format(''.join(str(time.time()).split('.'))) | |
jdata = json.dumps({ "metric": 'sys.cpu.test', "timestamp": t, "value": randint(500,900), "tags": { "host": "web03", "dc": "lga" } }) | |
if t == t_old: | |
continue | |
t_old = t | |
f = urllib2.urlopen('http://127.0.0.1:4242/api/put', jdata) | |
print 'Posted entry for t={}'.format(t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment