Created
September 15, 2016 19:28
-
-
Save yottatsa/69f8b73b65da0fa507b0c12e24115f9c to your computer and use it in GitHub Desktop.
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
__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