Skip to content

Instantly share code, notes, and snippets.

@blt
Created August 18, 2017 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blt/045160a243741d2390a03762900d4329 to your computer and use it in GitHub Desktop.
Save blt/045160a243741d2390a03762900d4329 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python2.7
import time
import socket
import sys
def graphite_metric(sock, name, value):
timestamp = int(time.time())
sock.send("%s %f %d\n" % (name, value, timestamp))
def main():
graphite_srv = ('localhost', 2004)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(graphite_srv)
while True:
graphite_metric(sock, "emit_packet", 1.0)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment