Skip to content

Instantly share code, notes, and snippets.

@tamale
Last active December 31, 2015 21:19
Show Gist options
  • Select an option

  • Save tamale/8046077 to your computer and use it in GitHub Desktop.

Select an option

Save tamale/8046077 to your computer and use it in GitHub Desktop.
kairosclient.py
#!/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