Last active
January 27, 2017 09:26
-
-
Save oprietop/2c5ed2b35fe07d3ac824a1fec38df29a to your computer and use it in GitHub Desktop.
Easy wrapper to push stuff to graphite
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
#!/usr/bin/env python2.7 | |
# -*- coding: utf8 -*- | |
import time | |
import random | |
import socket | |
def main(): | |
dic = {} | |
for i in range(1,10): | |
dic['key_'+str(i)] = random.randint(1, 100000) | |
return dic | |
if __name__ == "__main__": | |
while True: | |
dict = main() | |
message = '' | |
for k, v in dict.iteritems(): | |
message += 'python.%s %d %d\n' % (k, int(v), int(time.time())) | |
if message: | |
print '# payload:\n'+message | |
sock = socket.socket() | |
sock.connect(('127.0.0.1', 2003)) | |
sock.sendall(message) | |
sock.close() | |
time.sleep(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment