Skip to content

Instantly share code, notes, and snippets.

@yottatsa
Created September 15, 2016 19:28
Show Gist options
  • Save yottatsa/69f8b73b65da0fa507b0c12e24115f9c to your computer and use it in GitHub Desktop.
Save yottatsa/69f8b73b65da0fa507b0c12e24115f9c to your computer and use it in GitHub Desktop.
__author__ = 'yottatsa'
import uuid
import random
MEASUREMENTS = 'Memory_used;Memory_free;Memory_cached;Net_tx;Net_rx;Net_recv;Net_send;Disk_read;Disk_write;CPU_user;CPU_system;CPU_iowait'.lower().split(
';')
def host(i):
rnd = str(uuid.uuid4())
data = {"host": rnd[:8], "location": rnd[10], "cluster": rnd[11], "id": i}
return ','.join(['{}={}'.format(k, v) for k, v in data.items()])
def init_bucket(bucket_range):
return 0, [], random.randrange(*bucket_range)
def generate(num_hosts=1024, bucket_range=(10, 30, 2), db="test"):
p, bucket, t = init_bucket(bucket_range)
for h in [host(i) for i in xrange(num_hosts)]:
for m in MEASUREMENTS:
bucket.append(
"{},{} value={}".format(m, h, random.randint(1, 250)))
p = p + 1
if p > t:
pl = '\n'.join(bucket)
print "{} /write?db={}".format(len(pl), db)
print pl
p, bucket, t = init_bucket(bucket_range)
if __name__ == "__main__":
generate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment