Last active
December 31, 2015 21:19
-
-
Save tamale/8046077 to your computer and use it in GitHub Desktop.
kairosclient.py
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/env python | |
| # Inserts quasi-random sawtooth data into kairosdb over the telnet protocol | |
| import random | |
| import socket | |
| import time | |
| hostname = socket.gethostname() | |
| def collect_metric(name, value, timestamp): | |
| sock = socket.socket() | |
| sock.connect( ("stats01ea1", 4242) ) | |
| sock.send("put %s %d %d\n" % (name, timestamp, value)) | |
| sock.close() | |
| while True: | |
| now = time.time() | |
| millis = int((now - int(now)) * 1000) | |
| collect_metric("realtime.os.%s.bs.value" % hostname, int(random.random()*millis), int(now*1000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment